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

Upgrade to new dependency mockito-testng #10647

Merged
merged 13 commits into from
Oct 10, 2018
Merged

Upgrade to new dependency mockito-testng #10647

merged 13 commits into from
Oct 10, 2018

Conversation

skabashnyuk
Copy link
Contributor

@skabashnyuk skabashnyuk commented Aug 3, 2018

What does this PR do?

Upgrade to new dependency mockito-testng
Fixied issue in code related to this changes in mockito

Merge state

What issues does this PR fix or reference?

mockito/mockito#962
eclipse-che/che-parent#77
#10617

Upgrade to official mockito-testng artifact

Release Notes

Upgrade to official mockito-testng artifact

Docs PR

n/a

@@ -192,7 +191,8 @@ public void shouldDoNothingWhenTransportHttpReceived() throws Exception {
* with help real children {@link TransportHttp}, which returns real not null
* value. And then we can create mock {@link TransportHttp}.
*/
mock(Transport.class);

Choose a reason for hiding this comment

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

Is this change needed in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess yes. AFAIK @AndrienkoAleksandr was trying to explain why it needed in a comment about. New mockito just checking that mock is assigned to some variable and we can't just have mock in a vacuum.

@@ -225,7 +225,8 @@ public void testRethrowOnInvalidTokenBadRequestException() throws Exception {

@Test(expectedExceptions = {InfrastructureException.class})
public void testRethrowOnAnyException() throws Exception {
when(keycloakServiceClient.getIdentityProviderToken(anyString())).thenThrow(Exception.class);

Choose a reason for hiding this comment

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

Can you elaborate on why we need this change? I don't see any connection with the purpose of the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With new mockito code should only throw checked exceptions that match the signature of the stubbed. In this case, that was not true.

@@ -357,7 +357,7 @@ public void stopsWaitingAllMachineStartWhenOneMachineStartFailed() throws Except
final ImmutableMap<String, Pod> allPods =
ImmutableMap.of(WORKSPACE_POD_NAME, mockPod(ImmutableList.of(container1, container2)));
when(k8sEnv.getPods()).thenReturn(allPods);
doThrow(InfrastructureException.class).when(bootstrapper).bootstrapAsync();
doThrow(IllegalStateException.class).when(bootstrapper).bootstrapAsync();

Choose a reason for hiding this comment

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

Can you elaborate on why we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With new mockito code should only throw checked exceptions that match the signature of the stubbed. In this case, that was not true.

@@ -378,7 +378,7 @@ public void throwsInfrastructureExceptionWhenErrorOccursAndCleanupFailed() throw
doNothing().doThrow(InfrastructureException.class).when(namespace).cleanUp();
when(k8sEnv.getServices()).thenReturn(singletonMap("testService", mock(Service.class)));
when(services.create(any())).thenThrow(new InfrastructureException("service creation failed"));
doThrow(InfrastructureException.class).when(namespace).services();

Choose a reason for hiding this comment

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

Can you elaborate on why we need this change? I don't see any connection with the purpose of the PR.

Copy link
Contributor Author

@skabashnyuk skabashnyuk Aug 6, 2018

Choose a reason for hiding this comment

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

same as two comments above. With new mockito code should only throw checked exceptions that match the signature of the stubbed. In this case, that was not true.

@garagatyi
Copy link

@skabashnyuk thank you for the explanation!

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Aug 9, 2018
@musienko-maxim
Copy link
Contributor

ci-test

@riuvshin
Copy link
Contributor

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:10647
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov
Copy link
Contributor

ci-test

@riuvshin
Copy link
Contributor

riuvshin commented Oct 8, 2018

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:10647
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov
Copy link
Contributor

ci-test

@riuvshin
Copy link
Contributor

riuvshin commented Oct 8, 2018

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:10647
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov
Copy link
Contributor

ci-test

@riuvshin
Copy link
Contributor

riuvshin commented Oct 8, 2018

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:10647
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov
Copy link
Contributor

MockitoTestNG runs with enabled Strict Stubbing rules, so tests were adjusted to that:

  1. Removed usused stubs from test classes (stubbed methods that would never be invoked during test executions).
  2. In some cases, stubs would be counted as unused, when one is declared for multiple tests in @BeforeMethod, and at least one of the tests ends up not invoking the stubbed method. Usual solution to that is disabling strict checking for that stub using static method lenient().
  3. In case when same method would be stubbed with when().then() (but with different arguments), an exception will occur about unnecessary duplicated. To fix that, stubbing were reworked into doReturn().when().
  4. In other cases, when stubbing is intentionally declared, but not invoked, a lenient() method is used.

More info on how Strict Stubbing checking workes at:
https://static.javadoc.io/org.mockito/mockito-core/2.7.1/org/mockito/exceptions/misusing/PotentialStubbingProblem.html

@mkuznyetsov
Copy link
Contributor

ci-test

@riuvshin
Copy link
Contributor

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:10647
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@mkuznyetsov mkuznyetsov merged commit 65bd65e into master Oct 10, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 10, 2018
@benoitf benoitf added this to the 6.13.0 milestone Oct 10, 2018
nickboldt pushed a commit to nickboldt/che that referenced this pull request Oct 15, 2018
nickboldt pushed a commit to nickboldt/che that referenced this pull request Oct 15, 2018
@skabashnyuk skabashnyuk deleted the che10617 branch November 17, 2018 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants