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

JiraAPI Groovy Script conversion #3936

Merged
merged 15 commits into from
Jun 25, 2024

Conversation

TheMeinerLP
Copy link
Contributor

@TheMeinerLP TheMeinerLP commented May 23, 2024

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

@TheMeinerLP TheMeinerLP requested a review from a team as a code owner May 23, 2024 13:50
@NotMyFault
Copy link
Member

SpotBugs is not fine with that.

@TheMeinerLP
Copy link
Contributor Author

I will handle that

@NotMyFault NotMyFault requested a review from timja May 25, 2024 20:03
Copy link
Member

@timja timja left a 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

Copy link
Contributor

@gounthar gounthar left a 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! 👏

Copy link
Member

@timja timja left a 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.

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
@TheMeinerLP
Copy link
Contributor Author

I would like to keep the tests to simply check intended behaviour. There is no point in just checking return values.

@timja
Copy link
Member

timja commented Jun 12, 2024

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.

@TheMeinerLP
Copy link
Contributor Author

The goal of this PR is the conversion from groovy to java and improvement of the code in minimal.
And this is related to GSoC

@timja
Copy link
Member

timja commented Jun 12, 2024

The goal of this PR is the conversion from groovy to java and improvement of the code in minimal. And this is related to GSoC

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.

@TheMeinerLP
Copy link
Contributor Author

In what sense fragile ?
Because if I now add Enum and more, that goes against the goal of what the PR should do and what is still planned

@timja timja requested a review from NotMyFault June 12, 2024 15:44
@TheMeinerLP
Copy link
Contributor Author

@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?

@timja
Copy link
Member

timja commented Jun 19, 2024

@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.
The rest look like exceptions.
None of them are actually anything to do with the user being present in Jira and reporting false isn't correct.

If you return an exception instead that would be better and clearer.

I don't know where returning optionals would be useful.

@TheMeinerLP
Copy link
Contributor Author

Okay, understood, I'll implement it that way.

@TheMeinerLP TheMeinerLP requested a review from timja June 25, 2024 07:17
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@timja timja merged commit 4e5aa09 into jenkins-infra:master Jun 25, 2024
3 checks passed
@TheMeinerLP TheMeinerLP deleted the feature/jira-api-conversation branch June 25, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants