Skip to content
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

GoTimeUtilTest : Remove call to Optional.get() without isPresent() check #2970

Closed
2 tasks done
rohanKanojia opened this issue Apr 24, 2024 · 4 comments · Fixed by kushagrasinha123ks/jkube#1 or #2988
Closed
2 tasks done
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Apr 24, 2024

Component

JKube Kit

Task description

Description

In GoTimeUtilTest, we're directly calling Optional.get() without checking whether there is any element present in the Optional, this might cause NoSuchElementException :

@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);

We should check whether Optional.isPresent() returns true, then only fetch the value. We can rely on AssertJ's builtin isPresent() and contains(..) DSL methods to verify these things for us.

Expected Behavior

.isPresent() is added before directly checking value inside Optional

Acceptance Criteria

  • GoTimeUtilTest is refactored to not directly call Optional.get()
  • GoTimeUtilTest is passing after making these changes
@rohanKanojia rohanKanojia added good first issue Good for newcomers help wanted Extra attention is needed labels Apr 24, 2024
@kushagrasinha123ks
Copy link
Contributor

i would like to work on this issue, if available assign me.

@rohanKanojia
Copy link
Member Author

@kushagrasinha123ks Hello, help wanted issues are created for contributors who have already contributed to the project. I can see that you haven’t contributed to the project before.

Even if you are quite skilled, please consider doing one little (first-timers-only ) issue to get used to the process. After that, you are invited to move on up to the more difficult tasks, leaving some of the easy tasks to others so they can get involved and achieve change themselves.

Maybe you should start with issues created for first timers first-timers-only

@kushagrasinha123ks
Copy link
Contributor

kushagrasinha123ks commented Apr 26, 2024

Reply: I have successfully contributed to one (first-timers-only) issue, which is merged successfully for the ticket whose link i have provided for reference. Even if that's not eligible, i'll stick to first-timers-only. Also, i am unable to see my profile in contributors list, if you can comment on that.

@kushagrasinha123ks
Copy link
Contributor

I would request you to take a look on the last pull request, i have removed all the errors and it passed all the necessary checks.

@manusa manusa added this to the 1.17.0 milestone Apr 29, 2024 — with automated-tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment