-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
JiraAPI Groovy Script conversion #3936
JiraAPI Groovy Script conversion #3936
Conversation
SpotBugs is not fine with that. |
I will handle that |
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.
As a translation this seems ok.
Its not normal Java code, there's no reason that I can see for the abstract class.
It should be just one class in this instance.
It would be good to replace the verbose httpurlconnection with the HttpClient added in Java 11 but that should be looked at after a translation
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.
And it now builds! 👏
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 please remove all tests that are checking log messages? Test code not the contents of logging.
so e.g. isUserPresent
returns true or false based on different responses from Jira using something like wiremock.
src/test/java/io/jenkins/infra/repository_permissions_updater/JiraAPITest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/jenkins/infra/repository_permissions_updater/JiraAPITest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/jenkins/infra/repository_permissions_updater/JiraAPITest.java
Outdated
Show resolved
Hide resolved
I would like to keep the tests to simply check intended behaviour. There is no point in just checking return values. |
You could refactor to result types, e.g. an enum for some of the validation which would result in cleaner code. |
The goal of this PR is the conversion from groovy to java and improvement of the code in minimal. |
I understand that but the tests that you've added are fragile and in my opinion its not a great practice to test specific log messages unless they are an external interface to another system. |
In what sense fragile ? |
@timja Based on Alex's feedback I will add enum classes for the return values and use optionals to better catch the errors and add tests. Would you be happy with that? |
Looking at the code, there's one 'validation' error for the username regex. If you return an exception instead that would be better and clearer. I don't know where returning optionals would be useful. |
Okay, understood, I'll implement it that way. |
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.
Thanks!
In this PR I have converted the JiraAPI script into a Java class. I have reduced code and implemented better error handling.
API and implementation are separated and can be called via Singelton.
Overall, this PR should work simply because the classes and calls have the same names