-
Notifications
You must be signed in to change notification settings - Fork 102
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
[JENKINS-73690] Avoid null Enum to throw an exception #577
base: master
Are you sure you want to change the base?
Conversation
It's expected to be supported as there is an option to make the QueryParameter required. Positive test cases added as well.
mr.getParameterMap().put("status", null); | ||
RequestImpl req = new RequestImpl(new Stapler(), mr, Collections.emptyList(), null); | ||
try { | ||
new Function.InstanceFunction(getClass().getMethod("doRequireEnum", StaplerRequest.class, Status.class)) |
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.
Can you use assertThrows
for cleaner and less code in both these tests?
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.
I followed the pattern used in that class file, for the testMismatchingTypes
test case.
I usually prefer consistent style. Only occurrence of assertThrows is in Stapler2Test, compared to ~20 other occurrences of try/catch.
In a new project or if I was refactoring, yes I would have used assertThrows :)
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.
Imo you don't need to add harder to read code because existing code is hard to read.
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.
Depend on the perspective. If you look only at the diff, yes I agree, but if you look at the whole file, having different style make it harder. I expect to have more people reading the whole file compared to people reading only this PR/delta.
JENKINS-73690
#578
It's expected to be supported as there is an option to make the QueryParameter required. Positive test cases added as well.
Testing done
Tested using (new) unit tests, no manual tests outside that.
Submitter checklist