Skip to content

Commit

Permalink
refactor(web/test): replace deprecated mockito api verifyZeroInteract…
Browse files Browse the repository at this point in the history
…ions() with verifyNoMoreInteractions() during upgrade to spring boot 2.6.x (#1207)

While upgrading spring boot 2.6.15, encounter below errors in igor-web module during test compilation:
```
> Task :igor-web:compileTestJava FAILED
/igor/igor-web/src/test/java/com/netflix/spinnaker/igor/nexus/NexusEventPosterTest.java:21: error: cannot find symbol
import static org.mockito.Mockito.verifyZeroInteractions;
^
  symbol:   static verifyZeroInteractions
  location: class Mockito
/igor/igor-web/src/test/java/com/netflix/spinnaker/igor/nexus/NexusEventPosterTest.java:119: error: cannot find symbol
    verifyZeroInteractions(echoService);
    ^
  symbol:   method verifyZeroInteractions(EchoService)
  location: class NexusEventPosterTest
/igor/igor-web/src/test/java/com/netflix/spinnaker/igor/nexus/NexusEventPosterTest.java:129: error: cannot find symbol
    verifyZeroInteractions(echoService);
    ^
  symbol:   method verifyZeroInteractions(EchoService)
  location: class NexusEventPosterTest
/igor/igor-web/src/test/java/com/netflix/spinnaker/igor/nexus/NexusEventPosterTest.java:139: error: cannot find symbol
    verifyZeroInteractions(echoService);
    ^
  symbol:   method verifyZeroInteractions(EchoService)
  location: class NexusEventPosterTest
4 errors
```
Spring boot [2.6.15](https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.6.15/spring-boot-dependencies-2.6.15.pom) brings mockito 4.0.0 as transitive dependency. The `verifyZeroInteractions()` was deprecated in 3.x as mentioned here:
mockito/mockito-kotlin#383
And now it is removed from mockito 4.0.0.
To fix these issues, replacing `verifyZeroInteractions()` with `verifyNoMoreInteractions()`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
j-sandy and mergify[bot] authored Dec 20, 2023
1 parent 6d470ea commit 793665f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import com.netflix.spinnaker.igor.config.NexusProperties;
import com.netflix.spinnaker.igor.history.EchoService;
Expand Down Expand Up @@ -116,7 +116,7 @@ void postDeletedArtifactShouldNotSendEvent() {

nexusEventPoster.postEvent(payload);

verifyZeroInteractions(echoService);
verifyNoMoreInteractions(echoService);
}

@Test
Expand All @@ -126,7 +126,7 @@ void postNonPomArtifactShouldNotSendEvent() {

nexusEventPoster.postEvent(payload);

verifyZeroInteractions(echoService);
verifyNoMoreInteractions(echoService);
}

@Test
Expand All @@ -136,7 +136,7 @@ void postNonMatchingRepoArtifactShouldNotSendEvent() {

nexusEventPoster.postEvent(payload);

verifyZeroInteractions(echoService);
verifyNoMoreInteractions(echoService);
}

@Test
Expand Down

0 comments on commit 793665f

Please sign in to comment.