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

Update to junit5 and mockito #1550

Merged
merged 1 commit into from
May 25, 2022
Merged

Update to junit5 and mockito #1550

merged 1 commit into from
May 25, 2022

Conversation

chonton
Copy link
Contributor

@chonton chonton commented May 2, 2022

Mojo classes have many private fields changed to package-protected for unit tests to manipulate values.
junit updated from 4 to 5
jmockit migrated to mockito
multiple test frameworks removed in favor of junit5 capabilities

@chonton
Copy link
Contributor Author

chonton commented May 4, 2022

Rebased with buildx tests

@codecov
Copy link

codecov bot commented May 4, 2022

Codecov Report

Merging #1550 (e246a63) into master (ddf3029) will decrease coverage by 0.23%.
The diff coverage is 80.00%.

@@             Coverage Diff              @@
##             master    #1550      +/-   ##
============================================
- Coverage     62.88%   62.64%   -0.24%     
+ Complexity     2155     2139      -16     
============================================
  Files           170      170              
  Lines          9894     9882      -12     
  Branches       1354     1354              
============================================
- Hits           6222     6191      -31     
- Misses         3159     3176      +17     
- Partials        513      515       +2     
Impacted Files Coverage Δ
...va/io/fabric8/maven/docker/AbstractDockerMojo.java 34.56% <ø> (ø)
...rc/main/java/io/fabric8/maven/docker/CopyMojo.java 98.54% <ø> (ø)
...rc/main/java/io/fabric8/maven/docker/PushMojo.java 53.84% <ø> (ø)
.../main/java/io/fabric8/maven/docker/RemoveMojo.java 96.22% <ø> (ø)
...rc/main/java/io/fabric8/maven/docker/SaveMojo.java 83.33% <ø> (ø)
...rc/main/java/io/fabric8/maven/docker/StopMojo.java 43.24% <ø> (ø)
...ven/docker/access/hc/ApacheHttpClientDelegate.java 57.97% <ø> (ø)
...ric8/maven/docker/access/util/ExternalCommand.java 11.76% <0.00%> (-0.15%) ⬇️
...a/io/fabric8/maven/docker/util/JibServiceUtil.java 16.76% <0.00%> (-20.96%) ⬇️
.../docker/config/handler/property/ValueProvider.java 84.00% <100.00%> (ø)
... and 15 more

@chonton
Copy link
Contributor Author

chonton commented May 5, 2022

OK, finally works on windows.

@rohanKanojia rohanKanojia self-requested a review May 6, 2022 05:39
@rohanKanojia
Copy link
Member

Could you please review Sonar code smells and address whichever seem appropriate to you?

@chonton
Copy link
Contributor Author

chonton commented May 10, 2022

All SQ issues removed from 'new' code.

@chonton
Copy link
Contributor Author

chonton commented May 17, 2022

@rohanKanojia Ready to merge?

@rohanKanojia
Copy link
Member

Thanks, let me give it a quick review in a few days.

result = "linux/amd64";
}};
Mockito.doReturn(buildXService).when(serviceHub).getBuildXService();
// Mockito.doReturn(null).when(authConfigFactory).createAuthConfig(false, false, null, null, null, null);
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

excess mocking

Assertions.assertEquals("Response", response);
verifyHttpClientExecute((HttpUriRequest request, ResponseHandler responseHandler) -> {
Assertions.assertEquals(Collections.singletonMap("Accept", "*/*"), headersAsMap(request.getAllHeaders()));
/* assertThat(responseHandler)
Copy link
Member

Choose a reason for hiding this comment

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

why is this assertion commented? was it failing?

/* Mockito.verify(mockDelegate)
.post(Mockito.anyString(), Mockito.isNull(), Mockito.anyMap(), Mockito.any(ResponseHandler.class), Mockito.eq(200));

*/
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already verified in method thenPushSucceeded()

result = Collections.emptyList();
}};
Mockito.doReturn(oldImageId, newImageId).when(queryService).getImageId(name);
// Mockito.doReturn(Collections.emptyList()).when(docker).getImageTags("oldimage");
Copy link
Member

Choose a reason for hiding this comment

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

why is this commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

excess mocking. I have removed line

@sonarcloud
Copy link

sonarcloud bot commented May 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

81.2% 81.2% Coverage
0.0% 0.0% Duplication

@rohanKanojia rohanKanojia merged commit 3dd6acd into fabric8io:master May 25, 2022
@rohanKanojia
Copy link
Member

@chonton : Thanks a lot 💪

@chonton chonton deleted the junit5 branch May 25, 2022 17:37
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.

2 participants