New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update GoTimeUtilTest.java #2987
Update GoTimeUtilTest.java #2987
Conversation
GoTimeUtilTest is refactored to not directly call Optional.get().
Optional<INTEGER> optionalResult = GoTimeUtil.durationSeconds(duration); | ||
assertThat(optionalResult).isPresent(); | ||
assertThat(optionalResult).contains(expectedDuration); | ||
int result = optionalResult.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int result = optionalResult.get(); |
@@ -32,8 +33,10 @@ class GoTimeUtilTest { | |||
@ParameterizedTest(name = "duration ''{0}'' should be ''{1}'' seconds") | |||
@MethodSource("data") | |||
void conversion(String duration, int expectedDuration) { | |||
int result = GoTimeUtil.durationSeconds(duration).get(); | |||
assertThat(result).isEqualTo(expectedDuration); | |||
Optional<INTEGER> optionalResult = GoTimeUtil.durationSeconds(duration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional<INTEGER> optionalResult = GoTimeUtil.durationSeconds(duration); | |
Optional<Integer> optionalResult = GoTimeUtil.durationSeconds(duration); |
int result = GoTimeUtil.durationSeconds(duration).get(); | ||
assertThat(result).isEqualTo(expectedDuration); | ||
Optional<INTEGER> optionalResult = GoTimeUtil.durationSeconds(duration); | ||
assertThat(optionalResult).isPresent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat(optionalResult).isPresent(); | |
assertThat(optionalResult) | |
.isPresent() | |
.contains(expectedDuration); |
Thank you for resolving the error, I'll get on it. |
Description
Refactored GoTimeUtilTest to avoid directly calling Optional.get(). Now, the test checks whether the Optional contains a value before fetching it.
Fixes #2970
Type of change
test, version modification, documentation, etc.)
Checklist
git config user.name "Kushagra Sinha"
git config user.email "kushagrasinha123ks@gmail.com"
git commit --amend --signoff
git push origin kushagra/issue#2970 -f