Fix Mockito deprecations

See gh-18689
pull/18702/head
dreis2211 5 years ago committed by Stephane Nicoll
parent 511a2a073f
commit 8ecdf919f8

@ -38,7 +38,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link MeterRegistryConfigurer}.
@ -128,7 +128,7 @@ class MeterRegistryConfigurerTests {
MeterRegistryConfigurer configurer = new MeterRegistryConfigurer(createObjectProvider(this.customizers),
createObjectProvider(this.filters), createObjectProvider(this.binders), false, true);
configurer.configure(this.mockRegistry);
verifyZeroInteractions(this.mockBinder);
verifyNoInteractions(this.mockBinder);
}
@Test

@ -35,7 +35,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link HealthWebEndpointResponseMapper}.
@ -56,8 +56,8 @@ class HealthWebEndpointResponseMapperTests {
SecurityContext securityContext = mock(SecurityContext.class);
WebEndpointResponse<Health> response = mapper.mapDetails(supplier, securityContext);
assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
verifyZeroInteractions(supplier);
verifyZeroInteractions(securityContext);
verifyNoInteractions(supplier);
verifyNoInteractions(securityContext);
}
@Test
@ -68,7 +68,7 @@ class HealthWebEndpointResponseMapperTests {
WebEndpointResponse<Health> response = mapper.mapDetails(supplier, securityContext);
assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
assertThat(response.getBody()).isNull();
verifyZeroInteractions(supplier);
verifyNoInteractions(supplier);
verify(securityContext).isUserInRole("ACTUATOR");
}
@ -94,7 +94,7 @@ class HealthWebEndpointResponseMapperTests {
assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
assertThat(response.getBody()).isNull();
verify(supplier).get();
verifyZeroInteractions(securityContext);
verifyNoInteractions(securityContext);
}
@SuppressWarnings("unchecked")

@ -45,7 +45,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Integration tests for {@link LoggersEndpoint} when exposed via Jersey, Spring MVC, and
@ -165,7 +165,7 @@ class LoggersEndpointWebIntegrationTests {
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
.bodyValue(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus()
.isBadRequest();
verifyZeroInteractions(this.loggingSystem);
verifyNoInteractions(this.loggingSystem);
}
@WebEndpointTest

@ -44,7 +44,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link PrometheusPushGatewayManager}.
@ -162,7 +162,7 @@ class PrometheusPushGatewayManagerTests {
this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.NONE);
manager.shutdown();
verify(this.future).cancel(false);
verifyZeroInteractions(this.pushGateway);
verifyNoInteractions(this.pushGateway);
}
@Test

@ -40,7 +40,7 @@ import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link ImportAutoConfigurationImportSelector}.
@ -83,7 +83,7 @@ class ImportAutoConfigurationImportSelectorTests {
void propertyExclusionsAreNotApplied() throws Exception {
AnnotationMetadata annotationMetadata = getAnnotationMetadata(ImportFreeMarker.class);
this.importSelector.selectImports(annotationMetadata);
verifyZeroInteractions(this.environment);
verifyNoInteractions(this.environment);
}
@Test

@ -67,7 +67,7 @@ import org.springframework.util.Assert;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link QuartzAutoConfiguration}.
@ -157,7 +157,7 @@ class QuartzAutoConfigurationTests {
Scheduler scheduler = context.getBean(Scheduler.class);
assertThat(scheduler.getMetaData().getThreadPoolSize()).isEqualTo(50);
Executor executor = context.getBean(Executor.class);
verifyZeroInteractions(executor);
verifyNoInteractions(executor);
});
}

@ -42,7 +42,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link DispatcherFilter}.
@ -82,7 +82,7 @@ class DispatcherFilterTests {
ServletRequest request = mock(ServletRequest.class);
ServletResponse response = mock(ServletResponse.class);
this.filter.doFilter(request, response, this.chain);
verifyZeroInteractions(this.dispatcher);
verifyNoInteractions(this.dispatcher);
verify(this.chain).doFilter(request, response);
}
@ -100,7 +100,7 @@ class DispatcherFilterTests {
HttpServletResponse response = new MockHttpServletResponse();
willReturn(true).given(this.dispatcher).handle(any(ServerHttpRequest.class), any(ServerHttpResponse.class));
this.filter.doFilter(request, response, this.chain);
verifyZeroInteractions(this.chain);
verifyNoInteractions(this.chain);
verify(this.dispatcher).handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture());
ServerHttpRequest dispatcherRequest = this.serverRequestCaptor.getValue();
ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest;

@ -41,7 +41,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.withSettings;
/**
@ -91,7 +91,7 @@ class DispatcherTests {
given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler);
Dispatcher dispatcher = new Dispatcher(this.accessManager, Collections.singleton(mapper));
dispatcher.handle(this.serverRequest, this.serverResponse);
verifyZeroInteractions(handler);
verifyNoInteractions(handler);
assertThat(this.response.getStatus()).isEqualTo(403);
}

@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link Restarter}.
@ -136,7 +136,7 @@ class RestarterTests {
ObjectFactory objectFactory = mock(ObjectFactory.class);
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
assertThat(attribute).isEqualTo("abc");
verifyZeroInteractions(objectFactory);
verifyNoInteractions(objectFactory);
}
@Test

@ -38,7 +38,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link HttpRestartServer}.
@ -92,7 +92,7 @@ class HttpRestartServerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
verifyZeroInteractions(this.delegate);
verifyNoInteractions(this.delegate);
assertThat(response.getStatus()).isEqualTo(500);
}
@ -103,7 +103,7 @@ class HttpRestartServerTests {
MockHttpServletResponse response = new MockHttpServletResponse();
request.setContent(new byte[] { 0, 0, 0 });
this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
verifyZeroInteractions(this.delegate);
verifyNoInteractions(this.delegate);
assertThat(response.getStatus()).isEqualTo(500);
}

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link PropertyMappingContextCustomizerFactory}.
@ -53,7 +53,7 @@ class PropertyMappingContextCustomizerFactoryTests {
given(context.getEnvironment()).willReturn(environment);
given(context.getBeanFactory()).willReturn(beanFactory);
customizer.customizeContext(context, null);
verifyZeroInteractions(environment);
verifyNoInteractions(environment);
}
@Test

@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link SpringBootExceptionHandler}.
@ -43,7 +43,7 @@ class SpringBootExceptionHandlerTests {
Exception ex = new Exception();
this.handler.registerLoggedException(ex);
this.handler.uncaughtException(thread, ex);
verifyZeroInteractions(this.parent);
verifyNoInteractions(this.parent);
}
@Test

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link BindResult}.
@ -100,7 +100,7 @@ class BindResultTests {
void ifBoundWhenHasNoValueShouldNotCallConsumer() {
BindResult<String> result = BindResult.of(null);
result.ifBound(this.consumer);
verifyZeroInteractions(this.consumer);
verifyNoInteractions(this.consumer);
}
@Test
@ -121,7 +121,7 @@ class BindResultTests {
void mapWhenHasNoValueShouldNotCallMapper() {
BindResult<String> result = BindResult.of(null);
result.map(this.mapper);
verifyZeroInteractions(this.mapper);
verifyNoInteractions(this.mapper);
}
@Test
@ -140,7 +140,7 @@ class BindResultTests {
void orElseGetWhenHasValueShouldReturnValue() {
BindResult<String> result = BindResult.of("foo");
assertThat(result.orElseGet(this.supplier)).isEqualTo("foo");
verifyZeroInteractions(this.supplier);
verifyNoInteractions(this.supplier);
}
@Test

@ -26,8 +26,8 @@ import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/**
* Tests for {@link DeferredLog}.
@ -168,7 +168,7 @@ class DeferredLogTests {
verify(this.log).info("1", null);
verify(this.log).fatal("2", null);
verifyNoMoreInteractions(this.log);
verifyZeroInteractions(log2);
verifyNoInteractions(log2);
}
@SuppressWarnings("unchecked")

@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link TaskExecutorBuilder}.
@ -125,7 +125,7 @@ class TaskExecutorBuilderTests {
TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1)
.customizers(Collections.singleton(customizer2)).build();
verifyZeroInteractions(customizer1);
verifyNoInteractions(customizer1);
verify(customizer2).customize(executor);
}

@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link TaskSchedulerBuilder}.
@ -101,7 +101,7 @@ class TaskSchedulerBuilderTests {
TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class);
ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1)
.customizers(Collections.singleton(customizer2)).build();
verifyZeroInteractions(customizer1);
verifyNoInteractions(customizer1);
verify(customizer2).customize(scheduler);
}

@ -35,7 +35,7 @@ import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link LambdaSafe}.
@ -88,7 +88,7 @@ class LambdaSafeTests {
GenericCallback<?> callbackInstance = mock(StringBuilderCallback.class);
String argument = "foo";
LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).invoke((c) -> c.handle(argument));
verifyZeroInteractions(callbackInstance);
verifyNoInteractions(callbackInstance);
}
@Test
@ -164,7 +164,7 @@ class LambdaSafeTests {
InvocationResult<Integer> result = LambdaSafe.callback(GenericFactory.class, callbackInstance, argument)
.invokeAnd((c) -> c.handle(argument));
assertThat(result.hasResult()).isFalse();
verifyZeroInteractions(callbackInstance);
verifyNoInteractions(callbackInstance);
}
@Test
@ -229,7 +229,7 @@ class LambdaSafeTests {
String argument = "foo";
LambdaSafe.callbacks(GenericCallback.class, Collections.singleton(callbackInstance), argument)
.invoke((c) -> c.handle(null));
verifyZeroInteractions(callbackInstance);
verifyNoInteractions(callbackInstance);
}
@Test

@ -62,7 +62,7 @@ import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@ -391,7 +391,7 @@ class RestTemplateBuilderTests {
RestTemplateCustomizer customizer2 = mock(RestTemplateCustomizer.class);
RestTemplate template = this.builder.customizers(customizer1).customizers(Collections.singleton(customizer2))
.build();
verifyZeroInteractions(customizer1);
verifyNoInteractions(customizer1);
verify(customizer2).customize(template);
}

@ -47,7 +47,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* Tests for {@link WebServiceTemplateBuilder}.
@ -241,7 +241,7 @@ class WebServiceTemplateBuilderTests {
WebServiceTemplateCustomizer customizer2 = mock(WebServiceTemplateCustomizer.class);
WebServiceTemplate template = this.builder.customizers(customizer1)
.customizers(Collections.singleton(customizer2)).build();
verifyZeroInteractions(customizer1);
verifyNoInteractions(customizer1);
verify(customizer2).customize(template);
}

Loading…
Cancel
Save