Merge branch '2.7.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.audit.AuditEvent;
|
||||
import org.springframework.boot.actuate.audit.AuditEventRepository;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link AuditListener}.
|
||||
@@ -39,7 +39,7 @@ class AuditListenerTests {
|
||||
AuditEvent event = new AuditEvent("principal", "type", Collections.emptyMap());
|
||||
AuditListener listener = new AuditListener(repository);
|
||||
listener.onApplicationEvent(new AuditApplicationEvent(event));
|
||||
verify(repository).add(event);
|
||||
then(repository).should().add(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,9 +34,9 @@ import org.springframework.cache.support.SimpleCacheManager;
|
||||
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.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link CachesEndpoint}.
|
||||
@@ -126,8 +126,8 @@ class CachesEndpointTests {
|
||||
Cache b = mockCache("b");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a, b)));
|
||||
endpoint.clearCaches();
|
||||
verify(a).clear();
|
||||
verify(b).clear();
|
||||
then(a).should().clear();
|
||||
then(b).should().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,8 +136,8 @@ class CachesEndpointTests {
|
||||
Cache b = mockCache("b");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a, b)));
|
||||
assertThat(endpoint.clearCache("a", null)).isTrue();
|
||||
verify(a).clear();
|
||||
verify(b, never()).clear();
|
||||
then(a).should().clear();
|
||||
then(b).should(never()).clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,9 +161,9 @@ class CachesEndpointTests {
|
||||
cacheManagers.put("another", cacheManager(anotherA));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
|
||||
assertThat(endpoint.clearCache("a", "another")).isTrue();
|
||||
verify(a, never()).clear();
|
||||
verify(anotherA).clear();
|
||||
verify(b, never()).clear();
|
||||
then(a).should(never()).clear();
|
||||
then(anotherA).should().clear();
|
||||
then(b).should(never()).clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,7 +171,7 @@ class CachesEndpointTests {
|
||||
Cache a = mockCache("a");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a)));
|
||||
assertThat(endpoint.clearCache("unknown", null)).isFalse();
|
||||
verify(a, never()).clear();
|
||||
then(a).should(never()).clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +179,7 @@ class CachesEndpointTests {
|
||||
Cache a = mockCache("a");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", cacheManager(a)));
|
||||
assertThat(endpoint.clearCache("a", "unknown")).isFalse();
|
||||
verify(a, never()).clear();
|
||||
then(a).should(never()).clear();
|
||||
}
|
||||
|
||||
private CacheManager cacheManager(Cache... caches) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,8 +34,8 @@ import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link CouchbaseHealthIndicator}
|
||||
@@ -61,7 +61,7 @@ class CouchbaseHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
|
||||
assertThat(health.getDetails()).containsKey("endpoints");
|
||||
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(1);
|
||||
verify(cluster).diagnostics();
|
||||
then(cluster).should().diagnostics();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,7 +82,7 @@ class CouchbaseHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
|
||||
assertThat(health.getDetails()).containsKey("endpoints");
|
||||
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(2);
|
||||
verify(cluster).diagnostics();
|
||||
then(cluster).should().diagnostics();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,8 +35,8 @@ import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link CouchbaseReactiveHealthIndicator}.
|
||||
@@ -58,7 +58,7 @@ class CouchbaseReactiveHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
|
||||
assertThat(health.getDetails()).containsKey("endpoints");
|
||||
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(1);
|
||||
verify(cluster).diagnostics();
|
||||
then(cluster).should().diagnostics();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ class CouchbaseReactiveHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
|
||||
assertThat(health.getDetails()).containsKey("endpoints");
|
||||
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(2);
|
||||
verify(cluster).diagnostics();
|
||||
then(cluster).should().diagnostics();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,9 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConversionServiceParameterValueMapper}.
|
||||
@@ -47,7 +47,7 @@ class ConversionServiceParameterValueMapperTests {
|
||||
ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper(conversionService);
|
||||
Object mapped = mapper.mapParameterValue(new TestOperationParameter(Integer.class), "123");
|
||||
assertThat(mapped).isEqualTo(123);
|
||||
verify(conversionService).convert("123", Integer.class);
|
||||
then(conversionService).should().convert("123", Integer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
/**
|
||||
* Tests for {@link CachingOperationInvokerAdvisor}.
|
||||
@@ -86,7 +86,7 @@ class CachingOperationInvokerAdvisorTests {
|
||||
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters,
|
||||
this.invoker);
|
||||
assertThat(advised).isSameAs(this.invoker);
|
||||
verify(this.timeToLive).apply(EndpointId.of("foo"));
|
||||
then(this.timeToLive).should().apply(EndpointId.of("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +96,7 @@ class CachingOperationInvokerAdvisorTests {
|
||||
OperationInvoker advised = this.advisor.apply(EndpointId.of("foo"), OperationType.READ, parameters,
|
||||
this.invoker);
|
||||
assertThat(advised).isSameAs(this.invoker);
|
||||
verify(this.timeToLive).apply(EndpointId.of("foo"));
|
||||
then(this.timeToLive).should().apply(EndpointId.of("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,10 +39,9 @@ import static org.assertj.core.api.Assertions.as;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link CachingOperationInvoker}.
|
||||
@@ -144,10 +143,10 @@ class CachingOperationInvokerTests {
|
||||
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
||||
Object response = invoker.invoke(context);
|
||||
assertThat(response).isSameAs(expected);
|
||||
verify(target, times(1)).invoke(context);
|
||||
then(target).should().invoke(context);
|
||||
Object cachedResponse = invoker.invoke(context);
|
||||
assertThat(cachedResponse).isSameAs(response);
|
||||
verifyNoMoreInteractions(target);
|
||||
then(target).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,7 +161,7 @@ class CachingOperationInvokerTests {
|
||||
invoker.invoke(context);
|
||||
invoker.invoke(context);
|
||||
invoker.invoke(context);
|
||||
verify(target, times(3)).invoke(context);
|
||||
then(target).should(times(3)).invoke(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,7 +180,7 @@ class CachingOperationInvokerTests {
|
||||
assertThat(invoker.invoke(context)).isEqualTo(result1);
|
||||
assertThat(invoker.invoke(context)).isEqualTo(result2);
|
||||
assertThat(invoker.invoke(context)).isEqualTo(result3);
|
||||
verify(target, times(3)).invoke(context);
|
||||
then(target).should(times(3)).invoke(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -202,8 +201,8 @@ class CachingOperationInvokerTests {
|
||||
assertThat(invoker.invoke(authenticatedContext)).isEqualTo(authenticatedResult);
|
||||
assertThat(invoker.invoke(anonymousContext)).isEqualTo(anonymousResult);
|
||||
assertThat(invoker.invoke(authenticatedContext)).isEqualTo(authenticatedResult);
|
||||
verify(target, times(1)).invoke(anonymousContext);
|
||||
verify(target, times(1)).invoke(authenticatedContext);
|
||||
then(target).should().invoke(anonymousContext);
|
||||
then(target).should().invoke(authenticatedContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,7 +218,7 @@ class CachingOperationInvokerTests {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
invoker.invoke(context);
|
||||
verify(target, times(2)).invoke(context);
|
||||
then(target).should(times(2)).invoke(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,10 +235,10 @@ class CachingOperationInvokerTests {
|
||||
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
||||
Object responseV2 = invoker.invoke(contextV2);
|
||||
assertThat(responseV2).isSameAs(expectedV2);
|
||||
verify(target, times(1)).invoke(contextV2);
|
||||
then(target).should().invoke(contextV2);
|
||||
Object responseV3 = invoker.invoke(contextV3);
|
||||
assertThat(responseV3).isNotSameAs(responseV2);
|
||||
verify(target, times(1)).invoke(contextV3);
|
||||
then(target).should().invoke(contextV3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,10 +255,10 @@ class CachingOperationInvokerTests {
|
||||
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
||||
Object responseServer = invoker.invoke(contextServer);
|
||||
assertThat(responseServer).isSameAs(expectedServer);
|
||||
verify(target, times(1)).invoke(contextServer);
|
||||
then(target).should(times(1)).invoke(contextServer);
|
||||
Object responseManagement = invoker.invoke(contextManagement);
|
||||
assertThat(responseManagement).isNotSameAs(responseServer);
|
||||
verify(target, times(1)).invoke(contextManagement);
|
||||
then(target).should(times(1)).invoke(contextManagement);
|
||||
}
|
||||
|
||||
private static class MonoOperationInvoker implements OperationInvoker {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,9 +37,9 @@ import org.springframework.util.ClassUtils;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link EndpointMBean}.
|
||||
@@ -160,8 +160,8 @@ class EndpointMBeanTests {
|
||||
TestJmxOperationResponseMapper responseMapper = spy(this.responseMapper);
|
||||
EndpointMBean bean = new EndpointMBean(responseMapper, null, this.endpoint);
|
||||
bean.invoke("testOperation", NO_PARAMS, NO_SIGNATURE);
|
||||
verify(responseMapper).mapResponseType(String.class);
|
||||
verify(responseMapper).mapResponse("result");
|
||||
then(responseMapper).should().mapResponseType(String.class);
|
||||
then(responseMapper).should().mapResponse("result");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,8 +32,8 @@ import org.springframework.boot.test.json.BasicJsonTester;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link JacksonJmxOperationResponseMapper}
|
||||
@@ -59,7 +59,7 @@ class JacksonJmxOperationResponseMapperTests {
|
||||
JacksonJmxOperationResponseMapper mapper = new JacksonJmxOperationResponseMapper(objectMapper);
|
||||
Set<String> response = Collections.singleton("test");
|
||||
mapper.mapResponse(response);
|
||||
verify(objectMapper).convertValue(eq(response), any(JavaType.class));
|
||||
then(objectMapper).should().convertValue(eq(response), any(JavaType.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,8 +43,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link JmxEndpointExporter}.
|
||||
@@ -112,7 +112,7 @@ class JmxEndpointExporterTests {
|
||||
void afterPropertiesSetShouldRegisterMBeans() throws Exception {
|
||||
this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation()));
|
||||
this.exporter.afterPropertiesSet();
|
||||
verify(this.mBeanServer).registerMBean(this.objectCaptor.capture(), this.objectNameCaptor.capture());
|
||||
then(this.mBeanServer).should().registerMBean(this.objectCaptor.capture(), this.objectNameCaptor.capture());
|
||||
assertThat(this.objectCaptor.getValue()).isInstanceOf(EndpointMBean.class);
|
||||
assertThat(this.objectNameCaptor.getValue().getKeyProperty("name")).isEqualTo("test");
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class JmxEndpointExporterTests {
|
||||
void registerShouldUseObjectNameFactory() throws Exception {
|
||||
this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation()));
|
||||
this.exporter.afterPropertiesSet();
|
||||
verify(this.objectNameFactory).getObjectName(any(ExposableJmxEndpoint.class));
|
||||
then(this.objectNameFactory).should().getObjectName(any(ExposableJmxEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,7 +147,7 @@ class JmxEndpointExporterTests {
|
||||
this.endpoints.add(new TestExposableJmxEndpoint(new TestJmxOperation()));
|
||||
this.exporter.afterPropertiesSet();
|
||||
this.exporter.destroy();
|
||||
verify(this.mBeanServer).unregisterMBean(this.objectNameCaptor.capture());
|
||||
then(this.mBeanServer).should().unregisterMBean(this.objectNameCaptor.capture());
|
||||
assertThat(this.objectNameCaptor.getValue().getKeyProperty("name")).isEqualTo("test");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ServletEndpointRegistrar}.
|
||||
@@ -92,9 +92,9 @@ class ServletEndpointRegistrarTests {
|
||||
ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class));
|
||||
ServletEndpointRegistrar registrar = new ServletEndpointRegistrar(basePath, Collections.singleton(endpoint));
|
||||
registrar.onStartup(this.servletContext);
|
||||
verify(this.servletContext).addServlet(eq("test-actuator-endpoint"), this.servlet.capture());
|
||||
then(this.servletContext).should().addServlet(eq("test-actuator-endpoint"), this.servlet.capture());
|
||||
assertThat(this.servlet.getValue()).isInstanceOf(TestServlet.class);
|
||||
verify(this.dynamic).addMapping(expectedMapping);
|
||||
then(this.dynamic).should().addMapping(expectedMapping);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +104,7 @@ class ServletEndpointRegistrarTests {
|
||||
new EndpointServlet(TestServlet.class).withInitParameter("a", "b"));
|
||||
ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint));
|
||||
registrar.onStartup(this.servletContext);
|
||||
verify(this.dynamic).setInitParameters(Collections.singletonMap("a", "b"));
|
||||
then(this.dynamic).should().setInitParameters(Collections.singletonMap("a", "b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ class ServletEndpointRegistrarTests {
|
||||
ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class).withLoadOnStartup(7));
|
||||
ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint));
|
||||
registrar.onStartup(this.servletContext);
|
||||
verify(this.dynamic).setLoadOnStartup(7);
|
||||
then(this.dynamic).should().setLoadOnStartup(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,7 +122,7 @@ class ServletEndpointRegistrarTests {
|
||||
ExposableServletEndpoint endpoint = mockEndpoint(new EndpointServlet(TestServlet.class));
|
||||
ServletEndpointRegistrar registrar = new ServletEndpointRegistrar("/actuator", Collections.singleton(endpoint));
|
||||
registrar.onStartup(this.servletContext);
|
||||
verify(this.dynamic).setLoadOnStartup(-1);
|
||||
then(this.dynamic).should().setLoadOnStartup(-1);
|
||||
}
|
||||
|
||||
private ExposableServletEndpoint mockEndpoint(EndpointServlet endpointServlet) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
/**
|
||||
* Abstract base class for web endpoint integration tests.
|
||||
@@ -188,7 +188,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
void writeOperationWithVoidResponse() {
|
||||
load(VoidWriteResponseEndpointConfiguration.class, (context, client) -> {
|
||||
client.post().uri("/voidwrite").exchange().expectStatus().isNoContent().expectBody().isEmpty();
|
||||
verify(context.getBean(EndpointDelegate.class)).write();
|
||||
then(context.getBean(EndpointDelegate.class)).should().write();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
void deleteOperationWithVoidResponse() {
|
||||
load(VoidDeleteResponseEndpointConfiguration.class, (context, client) -> {
|
||||
client.delete().uri("/voiddelete").exchange().expectStatus().isNoContent().expectBody().isEmpty();
|
||||
verify(context.getBean(EndpointDelegate.class)).delete();
|
||||
then(context.getBean(EndpointDelegate.class)).should().delete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("foo", "one");
|
||||
client.post().uri("/test").bodyValue(body).exchange().expectStatus().isNoContent().expectBody().isEmpty();
|
||||
verify(context.getBean(EndpointDelegate.class)).write("one", null);
|
||||
then(context.getBean(EndpointDelegate.class)).should().write("one", null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
||||
load(TestEndpointConfiguration.class, (context, client) -> {
|
||||
client.post().uri("/test").contentType(MediaType.APPLICATION_JSON).exchange().expectStatus().isNoContent()
|
||||
.expectBody().isEmpty();
|
||||
verify(context.getBean(EndpointDelegate.class)).write(null, null);
|
||||
then(context.getBean(EndpointDelegate.class)).should().write(null, null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,8 @@ import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link InfluxDbHealthIndicator}.
|
||||
@@ -48,7 +48,7 @@ class InfluxDbHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("version")).isEqualTo("0.9");
|
||||
verify(influxDb).ping();
|
||||
then(influxDb).should().ping();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,7 +59,7 @@ class InfluxDbHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
|
||||
verify(influxDb).ping();
|
||||
then(influxDb).should().ping();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,8 @@ import org.springframework.integration.graph.IntegrationGraphServer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link IntegrationGraphEndpoint}.
|
||||
@@ -42,14 +42,14 @@ class IntegrationGraphEndpointTests {
|
||||
Graph mockedGraph = mock(Graph.class);
|
||||
given(this.server.getGraph()).willReturn(mockedGraph);
|
||||
Graph graph = this.endpoint.graph();
|
||||
verify(this.server).getGraph();
|
||||
then(this.server).should().getGraph();
|
||||
assertThat(graph).isEqualTo(mockedGraph);
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeOperationShouldRebuildGraph() {
|
||||
this.endpoint.rebuild();
|
||||
verify(this.server).rebuild();
|
||||
then(this.server).should().rebuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,9 +34,9 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DataSourceHealthIndicator}.
|
||||
@@ -106,7 +106,7 @@ class DataSourceHealthIndicatorTests {
|
||||
this.indicator.setDataSource(dataSource);
|
||||
Health health = this.indicator.health();
|
||||
assertThat(health.getDetails().get("database")).isNotNull();
|
||||
verify(connection, times(2)).close();
|
||||
then(connection).should(times(2)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,11 +30,10 @@ import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.BDDMockito.willThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link JmsHealthIndicator}.
|
||||
@@ -55,7 +54,7 @@ class JmsHealthIndicatorTests {
|
||||
Health health = indicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("provider")).isEqualTo("JMS test provider");
|
||||
verify(connection, times(1)).close();
|
||||
then(connection).should().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +79,7 @@ class JmsHealthIndicatorTests {
|
||||
Health health = indicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(health.getDetails().get("provider")).isNull();
|
||||
verify(connection, times(1)).close();
|
||||
then(connection).should().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,8 +27,8 @@ import org.springframework.ldap.core.LdapTemplate;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link LdapHealthIndicator}
|
||||
@@ -46,7 +46,7 @@ class LdapHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("version")).isEqualTo("3");
|
||||
verify(ldapTemplate).executeReadOnly((ContextExecutor<String>) any());
|
||||
then(ldapTemplate).should().executeReadOnly((ContextExecutor<String>) any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,7 +59,7 @@ class LdapHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
|
||||
verify(ldapTemplate).executeReadOnly((ContextExecutor<String>) any());
|
||||
then(ldapTemplate).should().executeReadOnly((ContextExecutor<String>) any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,8 +35,8 @@ import org.springframework.boot.logging.LoggingSystem;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link LoggersEndpoint}.
|
||||
@@ -120,25 +120,25 @@ class LoggersEndpointTests {
|
||||
@Test
|
||||
void configureLogLevelShouldSetLevelOnLoggingSystem() {
|
||||
new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("ROOT", LogLevel.DEBUG);
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureLogLevelWithNullSetsLevelOnLoggingSystemToNull() {
|
||||
new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("ROOT", null);
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", null);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureLogLevelInLoggerGroupShouldSetLevelOnLoggingSystem() {
|
||||
new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("test", LogLevel.DEBUG);
|
||||
verify(this.loggingSystem).setLogLevel("test.member", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureLogLevelWithNullInLoggerGroupShouldSetLevelOnLoggingSystem() {
|
||||
new LoggersEndpoint(this.loggingSystem, this.loggerGroups).configureLogLevel("test", null);
|
||||
verify(this.loggingSystem).setLogLevel("test.member", null);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member", null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,9 +43,8 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LoggersEndpoint} when exposed via Jersey, Spring MVC, and
|
||||
@@ -124,7 +123,7 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
|
||||
.isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
@@ -132,7 +131,7 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V2_JSON))
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
|
||||
.isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
@@ -140,7 +139,7 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON))
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
|
||||
.isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
@@ -148,8 +147,8 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V2_JSON))
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
|
||||
.isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("test.member1", LogLevel.DEBUG);
|
||||
verify(this.loggingSystem).setLogLevel("test.member2", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member1", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member2", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
@@ -157,8 +156,8 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/test").contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
|
||||
.isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("test.member1", LogLevel.DEBUG);
|
||||
verify(this.loggingSystem).setLogLevel("test.member2", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member1", LogLevel.DEBUG);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member2", LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
@@ -166,37 +165,37 @@ class LoggersEndpointWebIntegrationTests {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus()
|
||||
.isBadRequest();
|
||||
verifyNoInteractions(this.loggingSystem);
|
||||
then(this.loggingSystem).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void setLoggerWithNullLogLevel() {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON))
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", null);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", null);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void setLoggerWithNoLogLevel() {
|
||||
this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.parseMediaType(V3_JSON))
|
||||
.bodyValue(Collections.emptyMap()).exchange().expectStatus().isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", null);
|
||||
then(this.loggingSystem).should().setLogLevel("ROOT", null);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void setLoggerGroupWithNullLogLevel() {
|
||||
this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V3_JSON))
|
||||
.bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("test.member1", null);
|
||||
verify(this.loggingSystem).setLogLevel("test.member2", null);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member1", null);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member2", null);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void setLoggerGroupWithNoLogLevel() {
|
||||
this.client.post().uri("/actuator/loggers/test").contentType(MediaType.parseMediaType(V3_JSON))
|
||||
.bodyValue(Collections.emptyMap()).exchange().expectStatus().isNoContent();
|
||||
verify(this.loggingSystem).setLogLevel("test.member1", null);
|
||||
verify(this.loggingSystem).setLogLevel("test.member2", null);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member1", null);
|
||||
then(this.loggingSystem).should().setLogLevel("test.member2", null);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,11 +39,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
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.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link PrometheusPushGatewayManager}.
|
||||
@@ -110,9 +109,9 @@ class PrometheusPushGatewayManagerTests {
|
||||
void createShouldSchedulePushAsFixedRate() throws Exception {
|
||||
new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job",
|
||||
this.groupingKey, null);
|
||||
verify(this.scheduler).scheduleAtFixedRate(this.task.capture(), eq(this.pushRate));
|
||||
then(this.scheduler).should().scheduleAtFixedRate(this.task.capture(), eq(this.pushRate));
|
||||
this.task.getValue().run();
|
||||
verify(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey);
|
||||
then(this.pushGateway).should().pushAdd(this.registry, "job", this.groupingKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,7 +121,7 @@ class PrometheusPushGatewayManagerTests {
|
||||
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry,
|
||||
ownedScheduler, this.pushRate, "job", this.groupingKey, null);
|
||||
manager.shutdown();
|
||||
verify(ownedScheduler).shutdown();
|
||||
then(ownedScheduler).should().shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,7 +131,7 @@ class PrometheusPushGatewayManagerTests {
|
||||
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry,
|
||||
otherScheduler, this.pushRate, "job", this.groupingKey, null);
|
||||
manager.shutdown();
|
||||
verify(otherScheduler, never()).shutdown();
|
||||
then(otherScheduler).should(never()).shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,8 +140,8 @@ class PrometheusPushGatewayManagerTests {
|
||||
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry,
|
||||
this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.PUSH);
|
||||
manager.shutdown();
|
||||
verify(this.future).cancel(false);
|
||||
verify(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey);
|
||||
then(this.future).should().cancel(false);
|
||||
then(this.pushGateway).should().pushAdd(this.registry, "job", this.groupingKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,8 +150,8 @@ class PrometheusPushGatewayManagerTests {
|
||||
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry,
|
||||
this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.DELETE);
|
||||
manager.shutdown();
|
||||
verify(this.future).cancel(false);
|
||||
verify(this.pushGateway).delete("job", this.groupingKey);
|
||||
then(this.future).should().cancel(false);
|
||||
then(this.pushGateway).should().delete("job", this.groupingKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,15 +160,15 @@ class PrometheusPushGatewayManagerTests {
|
||||
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry,
|
||||
this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.NONE);
|
||||
manager.shutdown();
|
||||
verify(this.future).cancel(false);
|
||||
verifyNoInteractions(this.pushGateway);
|
||||
then(this.future).should().cancel(false);
|
||||
then(this.pushGateway).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void pushDoesNotThrowException() throws Exception {
|
||||
new PrometheusPushGatewayManager(this.pushGateway, this.registry, this.scheduler, this.pushRate, "job",
|
||||
this.groupingKey, null);
|
||||
verify(this.scheduler).scheduleAtFixedRate(this.task.capture(), eq(this.pushRate));
|
||||
then(this.scheduler).should().scheduleAtFixedRate(this.task.capture(), eq(this.pushRate));
|
||||
willThrow(RuntimeException.class).given(this.pushGateway).pushAdd(this.registry, "job", this.groupingKey);
|
||||
this.task.getValue().run();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
@@ -99,14 +99,14 @@ class StartupTimeMetricsListenerTests {
|
||||
|
||||
private ApplicationStartedEvent applicationStartedEvent(Long startupTimeMs) {
|
||||
SpringApplication application = mock(SpringApplication.class);
|
||||
doReturn(TestMainApplication.class).when(application).getMainApplicationClass();
|
||||
given(application.getMainApplicationClass()).willAnswer((invocation) -> TestMainApplication.class);
|
||||
return new ApplicationStartedEvent(application, null, null,
|
||||
(startupTimeMs != null) ? Duration.ofMillis(startupTimeMs) : null);
|
||||
}
|
||||
|
||||
private ApplicationReadyEvent applicationReadyEvent(Long startupTimeMs) {
|
||||
SpringApplication application = mock(SpringApplication.class);
|
||||
doReturn(TestMainApplication.class).when(application).getMainApplicationClass();
|
||||
given(application.getMainApplicationClass()).willAnswer((invocation) -> TestMainApplication.class);
|
||||
return new ApplicationReadyEvent(application, null, null,
|
||||
(startupTimeMs != null) ? Duration.ofMillis(startupTimeMs) : null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,8 +26,8 @@ import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link MongoHealthIndicator}.
|
||||
@@ -46,8 +46,8 @@ class MongoHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("version")).isEqualTo("2.6.4");
|
||||
verify(commandResult).getString("version");
|
||||
verify(mongoTemplate).executeCommand("{ buildInfo: 1 }");
|
||||
then(commandResult).should().getString("version");
|
||||
then(mongoTemplate).should().executeCommand("{ buildInfo: 1 }");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +58,7 @@ class MongoHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
|
||||
verify(mongoTemplate).executeCommand("{ buildInfo: 1 }");
|
||||
then(mongoTemplate).should().executeCommand("{ buildInfo: 1 }");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,9 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link Neo4jHealthIndicator}.
|
||||
@@ -100,7 +100,7 @@ class Neo4jHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
|
||||
verify(session, times(2)).close();
|
||||
then(session).should(times(2)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,9 +37,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link Neo4jReactiveHealthIndicator}.
|
||||
@@ -81,7 +81,7 @@ class Neo4jReactiveHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
|
||||
assertThat(health.getDetails()).containsEntry("edition", "some edition");
|
||||
}).verifyComplete();
|
||||
verify(session, times(2)).close();
|
||||
then(session).should(times(2)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -75,9 +75,8 @@ import org.springframework.util.MultiValueMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link QuartzEndpoint}.
|
||||
@@ -118,9 +117,9 @@ class QuartzEndpointTests {
|
||||
QuartzReport quartzReport = this.endpoint.quartzReport();
|
||||
assertThat(quartzReport.getJobs().getGroups()).containsOnly("jobSamples", "DEFAULT");
|
||||
assertThat(quartzReport.getTriggers().getGroups()).containsOnly("triggerSamples");
|
||||
verify(this.scheduler).getJobGroupNames();
|
||||
verify(this.scheduler).getTriggerGroupNames();
|
||||
verifyNoMoreInteractions(this.scheduler);
|
||||
then(this.scheduler).should().getJobGroupNames();
|
||||
then(this.scheduler).should().getTriggerGroupNames();
|
||||
then(this.scheduler).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -669,9 +668,9 @@ class QuartzEndpointTests {
|
||||
given(sanitizer.sanitize("secret", "value")).willReturn("----");
|
||||
QuartzJobDetails jobDetails = new QuartzEndpoint(this.scheduler, sanitizer).quartzJob("samples", "hello");
|
||||
assertThat(jobDetails.getData()).containsOnly(entry("test", "value"), entry("secret", "----"));
|
||||
verify(sanitizer).sanitize("test", "value");
|
||||
verify(sanitizer).sanitize("secret", "value");
|
||||
verifyNoMoreInteractions(sanitizer);
|
||||
then(sanitizer).should().sanitize("test", "value");
|
||||
then(sanitizer).should().sanitize("secret", "value");
|
||||
then(sanitizer).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
private void mockJobs(JobDetail... jobs) throws SchedulerException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,9 +33,9 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link RedisHealthIndicator}.
|
||||
@@ -77,7 +77,7 @@ class RedisHealthIndicatorTests {
|
||||
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
|
||||
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L);
|
||||
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L);
|
||||
verify(redisConnectionFactory, atLeastOnce()).getConnection();
|
||||
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +89,7 @@ class RedisHealthIndicatorTests {
|
||||
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
|
||||
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L);
|
||||
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L);
|
||||
verify(redisConnectionFactory, atLeastOnce()).getConnection();
|
||||
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +101,7 @@ class RedisHealthIndicatorTests {
|
||||
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
|
||||
assertThat(health.getDetails().get("slots_up")).isEqualTo(3L);
|
||||
assertThat(health.getDetails().get("slots_fail")).isEqualTo(1L);
|
||||
verify(redisConnectionFactory, atLeastOnce()).getConnection();
|
||||
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
|
||||
}
|
||||
|
||||
private RedisHealthIndicator createHealthIndicator(RedisConnection redisConnection) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,8 +34,8 @@ import org.springframework.data.redis.connection.ReactiveServerCommands;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link RedisReactiveHealthIndicator}.
|
||||
@@ -63,7 +63,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||
assertThat(h.getDetails()).containsOnlyKeys("version");
|
||||
assertThat(h.getDetails().get("version")).isEqualTo("2.8.9");
|
||||
}).verifyComplete();
|
||||
verify(redisConnection).closeLater();
|
||||
then(redisConnection).should().closeLater();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,7 +77,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||
assertThat(h.getDetails().get("slots_up")).isEqualTo(4L);
|
||||
assertThat(h.getDetails().get("slots_fail")).isEqualTo(0L);
|
||||
}).verifyComplete();
|
||||
verify(redisConnectionFactory.getReactiveConnection()).closeLater();
|
||||
then(redisConnectionFactory.getReactiveConnection()).should().closeLater();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +115,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||
Mono<Health> health = healthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
|
||||
.verifyComplete();
|
||||
verify(redisConnection).closeLater();
|
||||
then(redisConnection).should().closeLater();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,9 +35,9 @@ import org.springframework.security.web.authentication.switchuser.Authentication
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link AuthenticationAuditListener}.
|
||||
@@ -65,7 +65,7 @@ class AuthenticationAuditListenerTests {
|
||||
this.listener.onApplicationEvent(new InteractiveAuthenticationSuccessEvent(
|
||||
new UsernamePasswordAuthenticationToken("user", "password"), getClass()));
|
||||
// No need to audit this one (it shadows a regular AuthenticationSuccessEvent)
|
||||
verify(this.publisher, never()).publishEvent(any(ApplicationEvent.class));
|
||||
then(this.publisher).should(never()).publishEvent(any(ApplicationEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +105,7 @@ class AuthenticationAuditListenerTests {
|
||||
private AuditApplicationEvent handleAuthenticationEvent(AbstractAuthenticationEvent event) {
|
||||
ArgumentCaptor<AuditApplicationEvent> eventCaptor = ArgumentCaptor.forClass(AuditApplicationEvent.class);
|
||||
this.listener.onApplicationEvent(event);
|
||||
verify(this.publisher).publishEvent(eventCaptor.capture());
|
||||
then(this.publisher).should().publishEvent(eventCaptor.capture());
|
||||
return eventCaptor.getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,8 +33,8 @@ import org.springframework.security.authentication.AuthenticationCredentialsNotF
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link AuthorizationAuditListener}.
|
||||
@@ -82,7 +82,7 @@ class AuthorizationAuditListenerTests {
|
||||
private AuditApplicationEvent handleAuthorizationEvent(AbstractAuthorizationEvent event) {
|
||||
ArgumentCaptor<AuditApplicationEvent> eventCaptor = ArgumentCaptor.forClass(AuditApplicationEvent.class);
|
||||
this.listener.onApplicationEvent(event);
|
||||
verify(this.publisher).publishEvent(eventCaptor.capture());
|
||||
then(this.publisher).should().publishEvent(eventCaptor.capture());
|
||||
return eventCaptor.getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,8 @@ import org.springframework.session.Session;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link SessionsEndpoint}.
|
||||
@@ -80,7 +80,7 @@ class SessionsEndpointTests {
|
||||
@Test
|
||||
void deleteSession() {
|
||||
this.endpoint.deleteSession(session.getId());
|
||||
verify(this.repository).deleteById(session.getId());
|
||||
then(this.repository).should().deleteById(session.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrHealthIndicator}
|
||||
@@ -52,8 +51,8 @@ class SolrHealthIndicatorTests {
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.UP, 0, "root");
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,8 +61,8 @@ class SolrHealthIndicatorTests {
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(400));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.DOWN, 400, "root");
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,9 +73,9 @@ class SolrHealthIndicatorTests {
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.UP, 0, "particular core");
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verify(solrClient, times(1)).ping();
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,9 +86,9 @@ class SolrHealthIndicatorTests {
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(400));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.DOWN, 400, "particular core");
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verify(solrClient, times(1)).ping();
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,8 +100,8 @@ class SolrHealthIndicatorTests {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,12 +112,12 @@ class SolrHealthIndicatorTests {
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
healthIndicator.health();
|
||||
verify(solrClient, times(1)).request(any(CoreAdminRequest.class), isNull());
|
||||
verify(solrClient, times(1)).ping();
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
healthIndicator.health();
|
||||
verify(solrClient, times(2)).ping();
|
||||
verifyNoMoreInteractions(solrClient);
|
||||
then(solrClient).should(times(2)).ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
private void assertHealth(SolrHealthIndicator healthIndicator, Status expectedStatus, int expectedStatusCode,
|
||||
|
||||
Reference in New Issue
Block a user