Skip to content

Commit 0a330a6

Browse files
committed
refactor(core/test): replace deprecated mockito api verifyZeroInteractions() with verifyNoMoreInteractions() during upgrade to spring boot 2.6.x
While upgrading spring boot 2.6.15 and spring cloud 2021.0.8, encounter errors in kayenta-core module during test compilation: ``` > Task :kayenta-core:compileTestGroovy /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java:29: error: cannot find symbol import static org.mockito.Mockito.verifyZeroInteractions; ^ symbol: static verifyZeroInteractions location: class Mockito /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java:121: error: cannot find symbol verifyZeroInteractions(storageService); ^ symbol: method verifyZeroInteractions(StorageService) location: class SynchronousQueryProcessorTest /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java:201: error: cannot find symbol verifyZeroInteractions(storageService); ^ symbol: method verifyZeroInteractions(StorageService) location: class SynchronousQueryProcessorTest /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java:229: error: cannot find symbol verifyZeroInteractions(storageService); ^ symbol: method verifyZeroInteractions(StorageService) location: class SynchronousQueryProcessorTest /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java:259: error: cannot find symbol verifyZeroInteractions(storageService); ^ symbol: method verifyZeroInteractions(StorageService) location: class SynchronousQueryProcessorTest Note: /kayenta/kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors startup failed: Compilation failed; see the compiler error output for details. 1 error > Task :kayenta-core:compileTestGroovy FAILED ``` 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](https://github.com/mockito/mockito/releases/tag/v4.0.0). To fix these issues, replacing `verifyZeroInteractions()` with `verifyNoMoreInteractions()`
1 parent 3c71ecc commit 0a330a6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kayenta-core/src/test/groovy/com/netflix/kayenta/metrics/SynchronousQueryProcessorTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import static org.mockito.Mockito.mock;
2727
import static org.mockito.Mockito.times;
2828
import static org.mockito.Mockito.verify;
29-
import static org.mockito.Mockito.verifyZeroInteractions;
29+
import static org.mockito.Mockito.verifyNoMoreInteractions;
3030
import static org.mockito.Mockito.when;
3131
import static org.springframework.http.HttpStatus.BAD_GATEWAY;
3232
import static org.springframework.http.HttpStatus.BAD_REQUEST;
@@ -118,7 +118,7 @@ public void retriesRetryableHttpSeriesTillMaxAttemptsAndThrowsException() throws
118118
any(CanaryConfig.class),
119119
any(CanaryMetricConfig.class),
120120
any(CanaryScope.class));
121-
verifyZeroInteractions(storageService);
121+
verifyNoMoreInteractions(storageService);
122122
}
123123

124124
@Test
@@ -198,7 +198,7 @@ public void doesNotRetryNonRetryableHttpStatusAndThrowsException() throws IOExce
198198
any(CanaryConfig.class),
199199
any(CanaryMetricConfig.class),
200200
any(CanaryScope.class));
201-
verifyZeroInteractions(storageService);
201+
verifyNoMoreInteractions(storageService);
202202
}
203203

204204
@Test
@@ -226,7 +226,7 @@ public void retriesIoExceptionTillMaxAttemptsAndThrowsException() throws IOExcep
226226
any(CanaryConfig.class),
227227
any(CanaryMetricConfig.class),
228228
any(CanaryScope.class));
229-
verifyZeroInteractions(storageService);
229+
verifyNoMoreInteractions(storageService);
230230
}
231231

232232
@Test
@@ -256,7 +256,7 @@ public void retriesNetworkErrorTillMaxAttemptsAndThrowsException() throws IOExce
256256
any(CanaryConfig.class),
257257
any(CanaryMetricConfig.class),
258258
any(CanaryScope.class));
259-
verifyZeroInteractions(storageService);
259+
verifyNoMoreInteractions(storageService);
260260
}
261261

262262
private SpinnakerHttpException getSpinnakerHttpException(int status) {

0 commit comments

Comments
 (0)