Simplify AssertJ assertions and also make them more readable

See gh-33653
pull/33727/head
Krzysztof Krason 2 years ago committed by Moritz Halbritter
parent c9a2b2ab66
commit cf6493f65c

@ -45,8 +45,7 @@ class PackageTangleCheckTests {
@Test @Test
void whenPackagesAreTangledTaskFailsAndWritesAReport() throws Exception { void whenPackagesAreTangledTaskFailsAndWritesAReport() throws Exception {
prepareTask("tangled", (packageTangleCheck) -> { prepareTask("tangled", (packageTangleCheck) -> {
assertThatExceptionOfType(GradleException.class) assertThatExceptionOfType(GradleException.class).isThrownBy(packageTangleCheck::checkForPackageTangles);
.isThrownBy(() -> packageTangleCheck.checkForPackageTangles());
assertThat( assertThat(
new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt") new File(packageTangleCheck.getProject().getBuildDir(), "checkForPackageTangles/failure-report.txt")
.length()).isGreaterThan(0); .length()).isGreaterThan(0);

@ -55,7 +55,7 @@ class UpgradeApplicatorTests {
new Library("ActiveMQ", new LibraryVersion(DependencyVersion.parse("5.15.11"), null), null, null, null), new Library("ActiveMQ", new LibraryVersion(DependencyVersion.parse("5.15.11"), null), null, null, null),
DependencyVersion.parse("5.16"))); DependencyVersion.parse("5.16")));
String bomContents = Files.readString(bom.toPath()); String bomContents = Files.readString(bom.toPath());
assertThat(bomContents.length()).isEqualTo(originalContents.length() - 3); assertThat(bomContents).hasSize(originalContents.length() - 3);
} }
@Test @Test
@ -69,7 +69,7 @@ class UpgradeApplicatorTests {
new Upgrade(new Library("OAuth2 OIDC SDK", new LibraryVersion(DependencyVersion.parse("8.36.1"), null), new Upgrade(new Library("OAuth2 OIDC SDK", new LibraryVersion(DependencyVersion.parse("8.36.1"), null),
null, null, null), DependencyVersion.parse("8.36.2"))); null, null, null), DependencyVersion.parse("8.36.2")));
String bomContents = Files.readString(bom.toPath()); String bomContents = Files.readString(bom.toPath());
assertThat(bomContents.length()).isEqualTo(originalContents.length()); assertThat(bomContents).hasSameSizeAs(originalContents);
assertThat(bomContents).contains("version(\"8.36.2\")"); assertThat(bomContents).contains("version(\"8.36.2\")");
} }

@ -109,10 +109,10 @@ class ReleaseTrainDependencyVersionTests {
@Test @Test
void whenComparedWithADifferentDependencyVersionTypeThenTheResultsAreNonZero() { void whenComparedWithADifferentDependencyVersionTypeThenTheResultsAreNonZero() {
ReleaseTrainDependencyVersion dysprosium = ReleaseTrainDependencyVersion.parse("Dysprosium-SR16"); DependencyVersion dysprosium = ReleaseTrainDependencyVersion.parse("Dysprosium-SR16");
ArtifactVersionDependencyVersion twentyTwenty = ArtifactVersionDependencyVersion.parse("2020.0.0"); DependencyVersion twentyTwenty = ArtifactVersionDependencyVersion.parse("2020.0.0");
assertThat(dysprosium.compareTo(twentyTwenty)).isLessThan(0); assertThat(dysprosium).isLessThan(twentyTwenty);
assertThat(twentyTwenty.compareTo(dysprosium)).isGreaterThan(0); assertThat(twentyTwenty).isGreaterThan(dysprosium);
} }
private static ReleaseTrainDependencyVersion version(String input) { private static ReleaseTrainDependencyVersion version(String input) {

@ -39,8 +39,8 @@ class CompoundRowTests {
row.addProperty(new ConfigurationProperty("spring.test.third", "java.lang.String")); row.addProperty(new ConfigurationProperty("spring.test.third", "java.lang.String"));
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test]]<<my.spring.test,`+spring.test.first+` +" assertThat(asciidoc).hasToString("|[[my.spring.test]]<<my.spring.test,`+spring.test.first+` +" + NEWLINE
+ NEWLINE + "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + ">>" + NEWLINE + "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + ">>" + NEWLINE
+ "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE); + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
} }

@ -38,7 +38,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+something+`" + NEWLINE); + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+something+`" + NEWLINE);
} }
@ -49,7 +49,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE); + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
} }
@ -60,7 +60,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\|second+`" + NEWLINE); + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\|second+`" + NEWLINE);
} }
@ -71,7 +71,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\\\second+`" + NEWLINE); + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\\\second+`" + NEWLINE);
} }
@ -82,7 +82,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description with a \\| pipe.+++" + NEWLINE + "|" + NEWLINE); + NEWLINE + "|+++This is a description with a \\| pipe.+++" + NEWLINE + "|" + NEWLINE);
} }
@ -93,9 +93,8 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()) assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop.*+`>>"
.isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop.*+`>>" + NEWLINE + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
+ "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
} }
@Test @Test
@ -106,7 +105,7 @@ class SingleRowTests {
SingleRow row = new SingleRow(SNIPPET, property); SingleRow row = new SingleRow(SNIPPET, property);
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
row.write(asciidoc); row.write(asciidoc);
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first," + NEWLINE + "second," + NEWLINE + NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first," + NEWLINE + "second," + NEWLINE
+ "third+`" + NEWLINE); + "third+`" + NEWLINE);
} }

@ -41,17 +41,16 @@ class TableTests {
Asciidoc asciidoc = new Asciidoc(); Asciidoc asciidoc = new Asciidoc();
table.write(asciidoc); table.write(asciidoc);
// @formatter:off // @formatter:off
assertThat(asciidoc.toString()).isEqualTo( assertThat(asciidoc).hasToString("[cols=\"4,3,3\", options=\"header\"]" + NEWLINE +
"[cols=\"4,3,3\", options=\"header\"]" + NEWLINE + "|===" + NEWLINE +
"|===" + NEWLINE + "|Name|Description|Default Value" + NEWLINE + NEWLINE +
"|Name|Description|Default Value" + NEWLINE + NEWLINE + "|[[my.spring.test.other]]<<my.spring.test.other,`+spring.test.other+`>>" + NEWLINE +
"|[[my.spring.test.other]]<<my.spring.test.other,`+spring.test.other+`>>" + NEWLINE + "|+++This is another description.+++" + NEWLINE +
"|+++This is another description.+++" + NEWLINE + "|`+other value+`" + NEWLINE + NEWLINE +
"|`+other value+`" + NEWLINE + NEWLINE + "|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" + NEWLINE +
"|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" + NEWLINE + "|+++This is a description.+++" + NEWLINE +
"|+++This is a description.+++" + NEWLINE + "|`+something+`" + NEWLINE + NEWLINE +
"|`+something+`" + NEWLINE + NEWLINE + "|===" + NEWLINE);
"|===" + NEWLINE);
// @formatter:on // @formatter:on
} }

@ -80,8 +80,8 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
HealthEndpointGroups postProcessed = getPostProcessed("true"); HealthEndpointGroups postProcessed = getPostProcessed("true");
HealthEndpointGroup liveness = postProcessed.get("liveness"); HealthEndpointGroup liveness = postProcessed.get("liveness");
HealthEndpointGroup readiness = postProcessed.get("readiness"); HealthEndpointGroup readiness = postProcessed.get("readiness");
assertThat(liveness.getAdditionalPath().toString()).isEqualTo("server:/livez"); assertThat(liveness.getAdditionalPath()).hasToString("server:/livez");
assertThat(readiness.getAdditionalPath().toString()).isEqualTo("server:/readyz"); assertThat(readiness.getAdditionalPath()).hasToString("server:/readyz");
} }
@Test @Test
@ -99,8 +99,8 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
HealthEndpointGroups postProcessed = postProcessor.postProcessHealthEndpointGroups(groups); HealthEndpointGroups postProcessed = postProcessor.postProcessHealthEndpointGroups(groups);
HealthEndpointGroup liveness = postProcessed.get("liveness"); HealthEndpointGroup liveness = postProcessed.get("liveness");
HealthEndpointGroup readiness = postProcessed.get("readiness"); HealthEndpointGroup readiness = postProcessed.get("readiness");
assertThat(liveness.getAdditionalPath().toString()).isEqualTo("server:/livez"); assertThat(liveness.getAdditionalPath()).hasToString("server:/livez");
assertThat(readiness.getAdditionalPath().toString()).isEqualTo("server:/readyz"); assertThat(readiness.getAdditionalPath()).hasToString("server:/readyz");
} }
private HealthEndpointGroups getPostProcessed(String value) { private HealthEndpointGroups getPostProcessed(String value) {

@ -62,7 +62,7 @@ class CloudFoundryWebEndpointDiscovererTests {
void getEndpointsShouldAddCloudFoundryHealthExtension() { void getEndpointsShouldAddCloudFoundryHealthExtension() {
load(TestConfiguration.class, (discoverer) -> { load(TestConfiguration.class, (discoverer) -> {
Collection<ExposableWebEndpoint> endpoints = discoverer.getEndpoints(); Collection<ExposableWebEndpoint> endpoints = discoverer.getEndpoints();
assertThat(endpoints.size()).isEqualTo(2); assertThat(endpoints).hasSize(2);
for (ExposableWebEndpoint endpoint : endpoints) { for (ExposableWebEndpoint endpoint : endpoints) {
if (endpoint.getEndpointId().equals(EndpointId.of("health"))) { if (endpoint.getEndpointId().equals(EndpointId.of("health"))) {
WebOperation operation = findMainReadOperation(endpoint); WebOperation operation = findMainReadOperation(endpoint);

@ -117,7 +117,7 @@ class CloudFoundrySecurityInterceptorTests {
ArgumentCaptor<Token> tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class); ArgumentCaptor<Token> tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class);
then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture()); then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture());
Token token = tokenArgumentCaptor.getValue(); Token token = tokenArgumentCaptor.getValue();
assertThat(token.toString()).isEqualTo(accessToken); assertThat(token).hasToString(accessToken);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK);
assertThat(this.request.getAttribute("cloudFoundryAccessLevel")).isEqualTo(AccessLevel.FULL); assertThat(this.request.getAttribute("cloudFoundryAccessLevel")).isEqualTo(AccessLevel.FULL);
} }
@ -131,7 +131,7 @@ class CloudFoundrySecurityInterceptorTests {
ArgumentCaptor<Token> tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class); ArgumentCaptor<Token> tokenArgumentCaptor = ArgumentCaptor.forClass(Token.class);
then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture()); then(this.tokenValidator).should().validate(tokenArgumentCaptor.capture());
Token token = tokenArgumentCaptor.getValue(); Token token = tokenArgumentCaptor.getValue();
assertThat(token.toString()).isEqualTo(accessToken); assertThat(token).hasToString(accessToken);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK);
assertThat(this.request.getAttribute("cloudFoundryAccessLevel")).isEqualTo(AccessLevel.RESTRICTED); assertThat(this.request.getAttribute("cloudFoundryAccessLevel")).isEqualTo(AccessLevel.RESTRICTED);
} }

@ -151,7 +151,7 @@ class CloudFoundrySecurityServiceTests {
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));
Map<String, String> tokenKeys = this.securityService.fetchTokenKeys(); Map<String, String> tokenKeys = this.securityService.fetchTokenKeys();
this.server.verify(); this.server.verify();
assertThat(tokenKeys.get("test-key")).isEqualTo(tokenKeyValue); assertThat(tokenKeys).containsEntry("test-key", tokenKeyValue);
} }
@Test @Test
@ -163,7 +163,7 @@ class CloudFoundrySecurityServiceTests {
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));
Map<String, String> tokenKeys = this.securityService.fetchTokenKeys(); Map<String, String> tokenKeys = this.securityService.fetchTokenKeys();
this.server.verify(); this.server.verify();
assertThat(tokenKeys).hasSize(0); assertThat(tokenKeys).isEmpty();
} }
@Test @Test

@ -72,7 +72,7 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
ConfigurationPropertiesReportEndpointWebExtension endpoint = context ConfigurationPropertiesReportEndpointWebExtension endpoint = context
.getBean(ConfigurationPropertiesReportEndpointWebExtension.class); .getBean(ConfigurationPropertiesReportEndpointWebExtension.class);
Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles"); Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles");
assertThat(roles.contains("test")).isTrue(); assertThat(roles).contains("test");
}); });
} }
@ -119,8 +119,8 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
Map<String, Object> nestedProperties = properties.getContexts().get(context.getId()).getBeans() Map<String, Object> nestedProperties = properties.getContexts().get(context.getId()).getBeans()
.get("testProperties").getProperties(); .get("testProperties").getProperties();
assertThat(nestedProperties).isNotNull(); assertThat(nestedProperties).isNotNull();
assertThat(nestedProperties.get("dbPassword")).isEqualTo(dbPassword); assertThat(nestedProperties).containsEntry("dbPassword", dbPassword);
assertThat(nestedProperties.get("myTestProperty")).isEqualTo(myTestProperty); assertThat(nestedProperties).containsEntry("myTestProperty", myTestProperty);
}; };
} }

@ -51,20 +51,20 @@ class DefaultEndpointObjectNameFactoryTests {
@Test @Test
void generateObjectName() { void generateObjectName() {
ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test"))); ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test")));
assertThat(objectName.toString()).isEqualTo("org.springframework.boot:type=Endpoint,name=Test"); assertThat(objectName).hasToString("org.springframework.boot:type=Endpoint,name=Test");
} }
@Test @Test
void generateObjectNameWithCapitalizedId() { void generateObjectNameWithCapitalizedId() {
ObjectName objectName = generateObjectName(endpoint(EndpointId.of("testEndpoint"))); ObjectName objectName = generateObjectName(endpoint(EndpointId.of("testEndpoint")));
assertThat(objectName.toString()).isEqualTo("org.springframework.boot:type=Endpoint,name=TestEndpoint"); assertThat(objectName).hasToString("org.springframework.boot:type=Endpoint,name=TestEndpoint");
} }
@Test @Test
void generateObjectNameWithCustomDomain() { void generateObjectNameWithCustomDomain() {
this.properties.setDomain("com.example.acme"); this.properties.setDomain("com.example.acme");
ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test"))); ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test")));
assertThat(objectName.toString()).isEqualTo("com.example.acme:type=Endpoint,name=Test"); assertThat(objectName).hasToString("com.example.acme:type=Endpoint,name=Test");
} }
@Test @Test
@ -77,7 +77,7 @@ class DefaultEndpointObjectNameFactoryTests {
ExposableJmxEndpoint endpoint = endpoint(EndpointId.of("test")); ExposableJmxEndpoint endpoint = endpoint(EndpointId.of("test"));
String id = ObjectUtils.getIdentityHexString(endpoint); String id = ObjectUtils.getIdentityHexString(endpoint);
ObjectName objectName = generateObjectName(endpoint); ObjectName objectName = generateObjectName(endpoint);
assertThat(objectName.toString()).isEqualTo("org.springframework.boot:type=Endpoint,name=Test,identity=" + id); assertThat(objectName).hasToString("org.springframework.boot:type=Endpoint,name=Test,identity=" + id);
} }
@Test @Test
@ -96,8 +96,7 @@ class DefaultEndpointObjectNameFactoryTests {
given(this.mBeanServer.queryNames(new ObjectName("org.springframework.boot:type=Endpoint,name=Test,*"), null)) given(this.mBeanServer.queryNames(new ObjectName("org.springframework.boot:type=Endpoint,name=Test,*"), null))
.willReturn(Collections.singleton(new ObjectName("org.springframework.boot:type=Endpoint,name=Test"))); .willReturn(Collections.singleton(new ObjectName("org.springframework.boot:type=Endpoint,name=Test")));
ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test"))); ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test")));
assertThat(objectName.toString()) assertThat(objectName).hasToString("org.springframework.boot:type=Endpoint,name=Test,context=testContext");
.isEqualTo("org.springframework.boot:type=Endpoint,name=Test,context=testContext");
} }

@ -38,7 +38,7 @@ class WebEndpointPropertiesTests {
void basePathShouldBeCleaned() { void basePathShouldBeCleaned() {
WebEndpointProperties properties = new WebEndpointProperties(); WebEndpointProperties properties = new WebEndpointProperties();
properties.setBasePath("/"); properties.setBasePath("/");
assertThat(properties.getBasePath()).isEqualTo(""); assertThat(properties.getBasePath()).isEmpty();
properties.setBasePath("/actuator/"); properties.setBasePath("/actuator/");
assertThat(properties.getBasePath()).isEqualTo("/actuator"); assertThat(properties.getBasePath()).isEqualTo("/actuator");
} }
@ -54,7 +54,7 @@ class WebEndpointPropertiesTests {
void basePathCanBeEmpty() { void basePathCanBeEmpty() {
WebEndpointProperties properties = new WebEndpointProperties(); WebEndpointProperties properties = new WebEndpointProperties();
properties.setBasePath(""); properties.setBasePath("");
assertThat(properties.getBasePath()).isEqualTo(""); assertThat(properties.getBasePath()).isEmpty();
} }
} }

@ -92,7 +92,7 @@ class EnvironmentEndpointAutoConfigurationTests {
assertThat(context).hasSingleBean(EnvironmentEndpointWebExtension.class); assertThat(context).hasSingleBean(EnvironmentEndpointWebExtension.class);
EnvironmentEndpointWebExtension endpoint = context.getBean(EnvironmentEndpointWebExtension.class); EnvironmentEndpointWebExtension endpoint = context.getBean(EnvironmentEndpointWebExtension.class);
Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles"); Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles");
assertThat(roles.contains("test")).isTrue(); assertThat(roles).contains("test");
}); });
} }

@ -108,7 +108,7 @@ class InfoContributorAutoConfigurationTests {
assertThat(git).isInstanceOf(Map.class); assertThat(git).isInstanceOf(Map.class);
Map<String, Object> gitInfo = (Map<String, Object>) git; Map<String, Object> gitInfo = (Map<String, Object>) git;
assertThat(gitInfo).containsOnlyKeys("branch", "commit", "foo"); assertThat(gitInfo).containsOnlyKeys("branch", "commit", "foo");
assertThat(gitInfo.get("foo")).isEqualTo("bar"); assertThat(gitInfo).containsEntry("foo", "bar");
}); });
} }
@ -130,7 +130,7 @@ class InfoContributorAutoConfigurationTests {
assertThat(build).isInstanceOf(Map.class); assertThat(build).isInstanceOf(Map.class);
Map<String, Object> buildInfo = (Map<String, Object>) build; Map<String, Object> buildInfo = (Map<String, Object>) build;
assertThat(buildInfo).containsOnlyKeys("group", "artifact", "foo"); assertThat(buildInfo).containsOnlyKeys("group", "artifact", "foo");
assertThat(buildInfo.get("foo")).isEqualTo("bar"); assertThat(buildInfo).containsEntry("foo", "bar");
}); });
} }

@ -118,7 +118,7 @@ class MetricsAutoConfigurationIntegrationTests {
new ApplicationContextRunner().with(MetricsRun.limitedTo(GraphiteMetricsExportAutoConfiguration.class, new ApplicationContextRunner().with(MetricsRun.limitedTo(GraphiteMetricsExportAutoConfiguration.class,
JmxMetricsExportAutoConfiguration.class)).run((context) -> { JmxMetricsExportAutoConfiguration.class)).run((context) -> {
MeterRegistry composite = context.getBean(MeterRegistry.class); MeterRegistry composite = context.getBean(MeterRegistry.class);
assertThat(composite).extracting("filters", InstanceOfAssertFactories.ARRAY).hasSize(0); assertThat(composite).extracting("filters", InstanceOfAssertFactories.ARRAY).isEmpty();
assertThat(composite).isInstanceOf(CompositeMeterRegistry.class); assertThat(composite).isInstanceOf(CompositeMeterRegistry.class);
Set<MeterRegistry> registries = ((CompositeMeterRegistry) composite).getRegistries(); Set<MeterRegistry> registries = ((CompositeMeterRegistry) composite).getRegistries();
assertThat(registries).hasSize(2); assertThat(registries).hasSize(2);

@ -81,7 +81,7 @@ class MetricsAutoConfigurationMeterRegistryPostProcessorIntegrationTests {
Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class); Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class);
assertThat(registriesByName).hasSize(1); assertThat(registriesByName).hasSize(1);
MeterRegistry registry = registriesByName.values().iterator().next(); MeterRegistry registry = registriesByName.values().iterator().next();
assertThat(registry.get("logback.events").tag("level", "error").counter().count()).isEqualTo(1); assertThat(registry.get("logback.events").tag("level", "error").counter().count()).isOne();
}); });
} }
@ -95,10 +95,11 @@ class MetricsAutoConfigurationMeterRegistryPostProcessorIntegrationTests {
logger.error("Error."); logger.error("Error.");
Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class); Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class);
assertThat(registriesByName).hasSize(3); assertThat(registriesByName).hasSize(3);
registriesByName.forEach((name, registriesByName
registry) -> assertThat( .forEach((name,
registry.get("logback.events").tag("level", "error").counter().count()) registry) -> assertThat(
.isEqualTo(1)); registry.get("logback.events").tag("level", "error").counter().count())
.isOne());
}); });
} }

@ -54,7 +54,7 @@ class RepositoryMetricsAutoConfigurationIntegrationTests {
context.getBean(CityRepository.class).count(); context.getBean(CityRepository.class).count();
MeterRegistry registry = context.getBean(MeterRegistry.class); MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.get("spring.data.repository.invocations").tag("repository", "CityRepository").timer() assertThat(registry.get("spring.data.repository.invocations").tag("repository", "CityRepository").timer()
.count()).isEqualTo(1); .count()).isOne();
}); });
} }

@ -91,7 +91,7 @@ class JerseyServerMetricsAutoConfigurationTests {
doRequest(context); doRequest(context);
MeterRegistry registry = context.getBean(MeterRegistry.class); MeterRegistry registry = context.getBean(MeterRegistry.class);
Timer timer = registry.get("http.server.requests").tag("uri", "/users/{id}").timer(); Timer timer = registry.get("http.server.requests").tag("uri", "/users/{id}").timer();
assertThat(timer.count()).isEqualTo(1); assertThat(timer.count()).isOne();
}); });
} }

@ -59,7 +59,7 @@ class MongoMetricsAutoConfigurationTests {
this.contextRunner.with(MetricsRun.simple()) this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class)).run((context) -> {
assertThat(context).hasSingleBean(MongoMetricsCommandListener.class); assertThat(context).hasSingleBean(MongoMetricsCommandListener.class);
assertThat(getActualMongoClientSettingsUsedToConstructClient(context)).isNotNull() assertThat(getActualMongoClientSettingsUsedToConstructClient(context))
.extracting(MongoClientSettings::getCommandListeners).asList() .extracting(MongoClientSettings::getCommandListeners).asList()
.containsExactly(context.getBean(MongoMetricsCommandListener.class)); .containsExactly(context.getBean(MongoMetricsCommandListener.class));
assertThat(getMongoCommandTagsProviderUsedToConstructListener(context)) assertThat(getMongoCommandTagsProviderUsedToConstructListener(context))
@ -163,7 +163,7 @@ class MongoMetricsAutoConfigurationTests {
private ContextConsumer<AssertableApplicationContext> assertThatMetricsCommandListenerNotAdded() { private ContextConsumer<AssertableApplicationContext> assertThatMetricsCommandListenerNotAdded() {
return (context) -> { return (context) -> {
assertThat(context).doesNotHaveBean(MongoMetricsCommandListener.class); assertThat(context).doesNotHaveBean(MongoMetricsCommandListener.class);
assertThat(getActualMongoClientSettingsUsedToConstructClient(context)).isNotNull() assertThat(getActualMongoClientSettingsUsedToConstructClient(context))
.extracting(MongoClientSettings::getCommandListeners).asList().isEmpty(); .extracting(MongoClientSettings::getCommandListeners).asList().isEmpty();
}; };
} }

@ -140,7 +140,7 @@ class HibernateMetricsAutoConfigurationTests {
() -> (builder) -> builder.setBootstrapExecutor(new SimpleAsyncTaskExecutor())) () -> (builder) -> builder.setBootstrapExecutor(new SimpleAsyncTaskExecutor()))
.run((context) -> { .run((context) -> {
JdbcTemplate jdbcTemplate = new JdbcTemplate(context.getBean(DataSource.class)); JdbcTemplate jdbcTemplate = new JdbcTemplate(context.getBean(DataSource.class));
assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) from CITY", Integer.class)).isEqualTo(1); assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) from CITY", Integer.class)).isOne();
MeterRegistry registry = context.getBean(MeterRegistry.class); MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.get("hibernate.statements").tags("entityManagerFactory", "entityManagerFactory").meter(); registry.get("hibernate.statements").tags("entityManagerFactory", "entityManagerFactory").meter();
}); });

@ -57,10 +57,9 @@ class LettuceMetricsAutoConfigurationTests {
this.contextRunner.with(MetricsRun.simple()) this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class)).run((context) -> {
MicrometerOptions micrometerOptions = context.getBean(MicrometerOptions.class); MicrometerOptions micrometerOptions = context.getBean(MicrometerOptions.class);
assertThat(micrometerOptions.isEnabled()).isEqualTo(MicrometerOptions.DEFAULT_ENABLED); assertThat(micrometerOptions.isEnabled()).isTrue();
assertThat(micrometerOptions.isHistogram()).isEqualTo(MicrometerOptions.DEFAULT_HISTOGRAM); assertThat(micrometerOptions.isHistogram()).isFalse();
assertThat(micrometerOptions.localDistinction()) assertThat(micrometerOptions.localDistinction()).isFalse();
.isEqualTo(MicrometerOptions.DEFAULT_LOCAL_DISTINCTION);
assertThat(micrometerOptions.maxLatency()).isEqualTo(MicrometerOptions.DEFAULT_MAX_LATENCY); assertThat(micrometerOptions.maxLatency()).isEqualTo(MicrometerOptions.DEFAULT_MAX_LATENCY);
assertThat(micrometerOptions.minLatency()).isEqualTo(MicrometerOptions.DEFAULT_MIN_LATENCY); assertThat(micrometerOptions.minLatency()).isEqualTo(MicrometerOptions.DEFAULT_MIN_LATENCY);
}); });

@ -106,14 +106,14 @@ class MetricsIntegrationTests {
server.expect(once(), requestTo("/api/external")).andExpect(method(HttpMethod.GET)) server.expect(once(), requestTo("/api/external")).andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("{\"message\": \"hello\"}", MediaType.APPLICATION_JSON)); .andRespond(withSuccess("{\"message\": \"hello\"}", MediaType.APPLICATION_JSON));
assertThat(this.external.getForObject("/api/external", Map.class)).containsKey("message"); assertThat(this.external.getForObject("/api/external", Map.class)).containsKey("message");
assertThat(this.registry.get("http.client.requests").timer().count()).isEqualTo(1); assertThat(this.registry.get("http.client.requests").timer().count()).isOne();
} }
@Test @Test
void requestMappingIsInstrumented() { void requestMappingIsInstrumented() {
this.loopback.getForObject("/api/people", Set.class); this.loopback.getForObject("/api/people", Set.class);
waitAtMost(Duration.ofSeconds(5)).untilAsserted( waitAtMost(Duration.ofSeconds(5))
() -> assertThat(this.registry.get("http.server.requests").timer().count()).isEqualTo(1)); .untilAsserted(() -> assertThat(this.registry.get("http.server.requests").timer().count()).isOne());
} }

@ -149,7 +149,7 @@ class ObservationAutoConfigurationTests {
// When a DefaultMeterObservationHandler is registered, every stopped // When a DefaultMeterObservationHandler is registered, every stopped
// Observation leads to a timer // Observation leads to a timer
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
assertThat(meterRegistry.get("test-observation").timer().count()).isEqualTo(1); assertThat(meterRegistry.get("test-observation").timer().count()).isOne();
assertThat(context).hasSingleBean(DefaultMeterObservationHandler.class); assertThat(context).hasSingleBean(DefaultMeterObservationHandler.class);
assertThat(context).hasSingleBean(ObservationHandler.class); assertThat(context).hasSingleBean(ObservationHandler.class);
}); });
@ -170,7 +170,7 @@ class ObservationAutoConfigurationTests {
// This isn't allowed by ObservationPredicates.customPredicate // This isn't allowed by ObservationPredicates.customPredicate
Observation.start("observation2", observationRegistry).stop(); Observation.start("observation2", observationRegistry).stop();
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
assertThat(meterRegistry.get("observation1").timer().count()).isEqualTo(1); assertThat(meterRegistry.get("observation1").timer().count()).isOne();
assertThatThrownBy(() -> meterRegistry.get("observation2").timer()) assertThatThrownBy(() -> meterRegistry.get("observation2").timer())
.isInstanceOf(MeterNotFoundException.class); .isInstanceOf(MeterNotFoundException.class);
}); });

@ -117,7 +117,7 @@ class WebFluxObservationAutoConfigurationTests {
ObservationAutoConfiguration.class, WebFluxAutoConfiguration.class)) ObservationAutoConfiguration.class, WebFluxAutoConfiguration.class))
.withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((context) -> { .withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'http.server.requests'");
}); });
} }
@ -132,7 +132,7 @@ class WebFluxObservationAutoConfigurationTests {
"management.metrics.web.server.request.metric-name=my.http.server.requests") "management.metrics.web.server.request.metric-name=my.http.server.requests")
.run((context) -> { .run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("my.http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'");
}); });
} }
@ -146,7 +146,7 @@ class WebFluxObservationAutoConfigurationTests {
"management.observations.http.server.requests.name=my.http.server.requests") "management.observations.http.server.requests.name=my.http.server.requests")
.run((context) -> { .run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("my.http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'");
}); });
} }

@ -151,7 +151,7 @@ class WebMvcObservationAutoConfigurationTests {
ObservationAutoConfiguration.class, WebMvcAutoConfiguration.class)) ObservationAutoConfiguration.class, WebMvcAutoConfiguration.class))
.withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((context) -> { .withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'http.server.requests'");
}); });
} }
@ -166,7 +166,7 @@ class WebMvcObservationAutoConfigurationTests {
"management.metrics.web.server.request.metric-name=my.http.server.requests") "management.metrics.web.server.request.metric-name=my.http.server.requests")
.run((context) -> { .run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("my.http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'");
}); });
} }
@ -180,7 +180,7 @@ class WebMvcObservationAutoConfigurationTests {
"management.observations.http.server.requests.name=my.http.server.requests") "management.observations.http.server.requests.name=my.http.server.requests")
.run((context) -> { .run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("my.http.server.requests").meters().size()).isLessThanOrEqualTo(2); assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'");
}); });
} }

@ -96,7 +96,7 @@ class QuartzEndpointAutoConfigurationTests {
assertThat(context).hasSingleBean(QuartzEndpointWebExtension.class); assertThat(context).hasSingleBean(QuartzEndpointWebExtension.class);
QuartzEndpointWebExtension endpoint = context.getBean(QuartzEndpointWebExtension.class); QuartzEndpointWebExtension endpoint = context.getBean(QuartzEndpointWebExtension.class);
Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles"); Set<String> roles = (Set<String>) ReflectionTestUtils.getField(endpoint, "roles");
assertThat(roles.contains("test")).isTrue(); assertThat(roles).contains("test");
}); });
} }

@ -137,7 +137,7 @@ class BraveAutoConfigurationTests {
void shouldSupplyB3PropagationFactoryViaProperty() { void shouldSupplyB3PropagationFactoryViaProperty() {
this.contextRunner.withPropertyValues("management.tracing.propagation.type=B3").run((context) -> { this.contextRunner.withPropertyValues("management.tracing.propagation.type=B3").run((context) -> {
assertThat(context).hasBean("propagationFactory"); assertThat(context).hasBean("propagationFactory");
assertThat(context.getBean(Factory.class).toString()).isEqualTo("B3Propagation"); assertThat(context.getBean(Factory.class)).hasToString("B3Propagation");
assertThat(context).hasSingleBean(BaggagePropagation.FactoryBuilder.class); assertThat(context).hasSingleBean(BaggagePropagation.FactoryBuilder.class);
}); });
} }
@ -168,7 +168,7 @@ class BraveAutoConfigurationTests {
this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false", this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false",
"management.tracing.propagation.type=B3").run((context) -> { "management.tracing.propagation.type=B3").run((context) -> {
assertThat(context).hasBean("propagationFactory"); assertThat(context).hasBean("propagationFactory");
assertThat(context.getBean(Factory.class).toString()).isEqualTo("B3Propagation"); assertThat(context.getBean(Factory.class)).hasToString("B3Propagation");
assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class); assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class);
}); });
} }

@ -47,7 +47,7 @@ class MeterRegistrySpanMetricsTests {
@Test @Test
void reportDroppedShouldIncreaseCounter() { void reportDroppedShouldIncreaseCounter() {
this.sut.reportDropped(); this.sut.reportDropped();
assertThat(getCounterValue("wavefront.reporter.spans.dropped")).isEqualTo(1); assertThat(getCounterValue("wavefront.reporter.spans.dropped")).isOne();
this.sut.reportDropped(); this.sut.reportDropped();
assertThat(getCounterValue("wavefront.reporter.spans.dropped")).isEqualTo(2); assertThat(getCounterValue("wavefront.reporter.spans.dropped")).isEqualTo(2);
} }
@ -55,7 +55,7 @@ class MeterRegistrySpanMetricsTests {
@Test @Test
void reportReceivedShouldIncreaseCounter() { void reportReceivedShouldIncreaseCounter() {
this.sut.reportReceived(); this.sut.reportReceived();
assertThat(getCounterValue("wavefront.reporter.spans.received")).isEqualTo(1); assertThat(getCounterValue("wavefront.reporter.spans.received")).isOne();
this.sut.reportReceived(); this.sut.reportReceived();
assertThat(getCounterValue("wavefront.reporter.spans.received")).isEqualTo(2); assertThat(getCounterValue("wavefront.reporter.spans.received")).isEqualTo(2);
} }
@ -63,7 +63,7 @@ class MeterRegistrySpanMetricsTests {
@Test @Test
void reportErrorsShouldIncreaseCounter() { void reportErrorsShouldIncreaseCounter() {
this.sut.reportErrors(); this.sut.reportErrors();
assertThat(getCounterValue("wavefront.reporter.errors")).isEqualTo(1); assertThat(getCounterValue("wavefront.reporter.errors")).isOne();
this.sut.reportErrors(); this.sut.reportErrors();
assertThat(getCounterValue("wavefront.reporter.errors")).isEqualTo(2); assertThat(getCounterValue("wavefront.reporter.errors")).isEqualTo(2);
} }
@ -72,9 +72,9 @@ class MeterRegistrySpanMetricsTests {
void registerQueueSizeShouldCreateGauge() { void registerQueueSizeShouldCreateGauge() {
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2); BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2);
this.sut.registerQueueSize(queue); this.sut.registerQueueSize(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.size")).isEqualTo(0); assertThat(getGaugeValue("wavefront.reporter.queue.size")).isZero();
queue.offer(1); queue.offer(1);
assertThat(getGaugeValue("wavefront.reporter.queue.size")).isEqualTo(1); assertThat(getGaugeValue("wavefront.reporter.queue.size")).isOne();
} }
@Test @Test
@ -83,7 +83,7 @@ class MeterRegistrySpanMetricsTests {
this.sut.registerQueueRemainingCapacity(queue); this.sut.registerQueueRemainingCapacity(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(2); assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(2);
queue.offer(1); queue.offer(1);
assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(1); assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isOne();
} }
private double getGaugeValue(String name) { private double getGaugeValue(String name) {

@ -35,14 +35,14 @@ class ManagementContextConfigurationTests {
void proxyBeanMethodsIsEnabledByDefault() { void proxyBeanMethodsIsEnabledByDefault() {
AnnotationAttributes attributes = AnnotatedElementUtils AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(DefaultManagementContextConfiguration.class, Configuration.class); .getMergedAnnotationAttributes(DefaultManagementContextConfiguration.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true); assertThat(attributes).containsEntry("proxyBeanMethods", true);
} }
@Test @Test
void proxyBeanMethodsCanBeDisabled() { void proxyBeanMethodsCanBeDisabled() {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes( AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(
NoBeanMethodProxyingManagementContextConfiguration.class, Configuration.class); NoBeanMethodProxyingManagementContextConfiguration.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false); assertThat(attributes).containsEntry("proxyBeanMethods", false);
} }
@ManagementContextConfiguration @ManagementContextConfiguration

@ -44,7 +44,7 @@ class ManagementServerPropertiesTests {
@Test @Test
void defaultBasePathIsEmptyString() { void defaultBasePathIsEmptyString() {
ManagementServerProperties properties = new ManagementServerProperties(); ManagementServerProperties properties = new ManagementServerProperties();
assertThat(properties.getBasePath()).isEqualTo(""); assertThat(properties.getBasePath()).isEmpty();
} }
@Test @Test
@ -65,7 +65,7 @@ class ManagementServerPropertiesTests {
void slashOfBasePathIsDefaultValue() { void slashOfBasePathIsDefaultValue() {
ManagementServerProperties properties = new ManagementServerProperties(); ManagementServerProperties properties = new ManagementServerProperties();
properties.setBasePath("/"); properties.setBasePath("/");
assertThat(properties.getBasePath()).isEqualTo(""); assertThat(properties.getBasePath()).isEmpty();
} }
} }

@ -37,7 +37,7 @@ class AuditEventTests {
@Test @Test
void nowEvent() { void nowEvent() {
AuditEvent event = new AuditEvent("phil", "UNKNOWN", Collections.singletonMap("a", "b")); AuditEvent event = new AuditEvent("phil", "UNKNOWN", Collections.singletonMap("a", "b"));
assertThat(event.getData().get("a")).isEqualTo("b"); assertThat(event.getData()).containsEntry("a", "b");
assertThat(event.getType()).isEqualTo("UNKNOWN"); assertThat(event.getType()).isEqualTo("UNKNOWN");
assertThat(event.getPrincipal()).isEqualTo("phil"); assertThat(event.getPrincipal()).isEqualTo("phil");
assertThat(event.getTimestamp()).isNotNull(); assertThat(event.getTimestamp()).isNotNull();
@ -46,8 +46,8 @@ class AuditEventTests {
@Test @Test
void convertStringsToData() { void convertStringsToData() {
AuditEvent event = new AuditEvent("phil", "UNKNOWN", "a=b", "c=d"); AuditEvent event = new AuditEvent("phil", "UNKNOWN", "a=b", "c=d");
assertThat(event.getData().get("a")).isEqualTo("b"); assertThat(event.getData()).containsEntry("a", "b");
assertThat(event.getData().get("c")).isEqualTo("d"); assertThat(event.getData()).containsEntry("c", "d");
} }
@Test @Test

@ -42,7 +42,7 @@ class InMemoryAuditEventRepositoryTests {
repository.add(new AuditEvent("dave", "a")); repository.add(new AuditEvent("dave", "a"));
repository.add(new AuditEvent("dave", "b")); repository.add(new AuditEvent("dave", "b"));
List<AuditEvent> events = repository.find("dave", null, null); List<AuditEvent> events = repository.find("dave", null, null);
assertThat(events.size()).isEqualTo(2); assertThat(events).hasSize(2);
assertThat(events.get(0).getType()).isEqualTo("a"); assertThat(events.get(0).getType()).isEqualTo("a");
assertThat(events.get(1).getType()).isEqualTo("b"); assertThat(events.get(1).getType()).isEqualTo("b");
} }
@ -54,7 +54,7 @@ class InMemoryAuditEventRepositoryTests {
repository.add(new AuditEvent("dave", "b")); repository.add(new AuditEvent("dave", "b"));
repository.add(new AuditEvent("dave", "c")); repository.add(new AuditEvent("dave", "c"));
List<AuditEvent> events = repository.find("dave", null, null); List<AuditEvent> events = repository.find("dave", null, null);
assertThat(events.size()).isEqualTo(2); assertThat(events).hasSize(2);
assertThat(events.get(0).getType()).isEqualTo("b"); assertThat(events.get(0).getType()).isEqualTo("b");
assertThat(events.get(1).getType()).isEqualTo("c"); assertThat(events.get(1).getType()).isEqualTo("c");
} }
@ -74,7 +74,7 @@ class InMemoryAuditEventRepositoryTests {
repository.add(new AuditEvent("dave", "c")); repository.add(new AuditEvent("dave", "c"));
repository.add(new AuditEvent("phil", "d")); repository.add(new AuditEvent("phil", "d"));
List<AuditEvent> events = repository.find("dave", null, null); List<AuditEvent> events = repository.find("dave", null, null);
assertThat(events.size()).isEqualTo(2); assertThat(events).hasSize(2);
assertThat(events.get(0).getType()).isEqualTo("a"); assertThat(events.get(0).getType()).isEqualTo("a");
assertThat(events.get(1).getType()).isEqualTo("c"); assertThat(events.get(1).getType()).isEqualTo("c");
} }
@ -87,7 +87,7 @@ class InMemoryAuditEventRepositoryTests {
repository.add(new AuditEvent("dave", "c")); repository.add(new AuditEvent("dave", "c"));
repository.add(new AuditEvent("phil", "d")); repository.add(new AuditEvent("phil", "d"));
List<AuditEvent> events = repository.find("dave", null, "a"); List<AuditEvent> events = repository.find("dave", null, "a");
assertThat(events.size()).isEqualTo(1); assertThat(events).hasSize(1);
assertThat(events.get(0).getPrincipal()).isEqualTo("dave"); assertThat(events.get(0).getPrincipal()).isEqualTo("dave");
assertThat(events.get(0).getType()).isEqualTo("a"); assertThat(events.get(0).getType()).isEqualTo("a");
} }
@ -103,11 +103,11 @@ class InMemoryAuditEventRepositoryTests {
repository.add(new AuditEvent(instant.plus(3, ChronoUnit.DAYS), "phil", "d", data)); repository.add(new AuditEvent(instant.plus(3, ChronoUnit.DAYS), "phil", "d", data));
Instant after = instant.plus(1, ChronoUnit.DAYS); Instant after = instant.plus(1, ChronoUnit.DAYS);
List<AuditEvent> events = repository.find(null, after, null); List<AuditEvent> events = repository.find(null, after, null);
assertThat(events.size()).isEqualTo(2); assertThat(events).hasSize(2);
assertThat(events.get(0).getType()).isEqualTo("c"); assertThat(events.get(0).getType()).isEqualTo("c");
assertThat(events.get(1).getType()).isEqualTo("d"); assertThat(events.get(1).getType()).isEqualTo("d");
events = repository.find("dave", after, null); events = repository.find("dave", after, null);
assertThat(events.size()).isEqualTo(1); assertThat(events).hasSize(1);
assertThat(events.get(0).getType()).isEqualTo("c"); assertThat(events.get(0).getType()).isEqualTo("c");
} }

@ -52,7 +52,7 @@ class BeansEndpointTests {
ContextBeansDescriptor descriptor = result.getContexts().get(context.getId()); ContextBeansDescriptor descriptor = result.getContexts().get(context.getId());
assertThat(descriptor.getParentId()).isNull(); assertThat(descriptor.getParentId()).isNull();
Map<String, BeanDescriptor> beans = descriptor.getBeans(); Map<String, BeanDescriptor> beans = descriptor.getBeans();
assertThat(beans.size()).isLessThanOrEqualTo(context.getBeanDefinitionCount()); assertThat(beans).hasSizeLessThanOrEqualTo(context.getBeanDefinitionCount());
assertThat(beans).containsKey("endpoint"); assertThat(beans).containsKey("endpoint");
}); });
} }

@ -120,7 +120,7 @@ class CassandraDriverHealthIndicatorTests {
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session); CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo(Version.V4_0_0); assertThat(health.getDetails()).containsEntry("version", Version.V4_0_0);
} }
@Test @Test
@ -129,7 +129,7 @@ class CassandraDriverHealthIndicatorTests {
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session); CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isNull(); assertThat(health.getDetails()).doesNotContainKey("version");
} }
@Test @Test
@ -139,8 +139,8 @@ class CassandraDriverHealthIndicatorTests {
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session); CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("error")) assertThat(health.getDetails()).containsEntry("error",
.isEqualTo(DriverTimeoutException.class.getName() + ": Test Exception"); DriverTimeoutException.class.getName() + ": Test Exception");
} }
private CqlSession mockCqlSessionWithNodeState(NodeState... nodeStates) { private CqlSession mockCqlSessionWithNodeState(NodeState... nodeStates) {

@ -131,7 +131,7 @@ class CassandraDriverReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version"); assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails().get("version")).isEqualTo(Version.V4_0_0); assertThat(h.getDetails()).containsEntry("version", Version.V4_0_0);
}).verifyComplete(); }).verifyComplete();
} }
@ -142,7 +142,7 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health(); Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails().get("version")).isNull(); assertThat(h.getDetails()).doesNotContainKey("version");
}).verifyComplete(); }).verifyComplete();
} }
@ -156,8 +156,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN); assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails()).containsOnlyKeys("error"); assertThat(h.getDetails()).containsOnlyKeys("error");
assertThat(h.getDetails().get("error")) assertThat(h.getDetails()).containsEntry("error",
.isEqualTo(DriverTimeoutException.class.getName() + ": Test Exception"); DriverTimeoutException.class.getName() + ": Test Exception");
}).verifyComplete(); }).verifyComplete();
} }

@ -109,7 +109,7 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
.filter((id) -> findIdFromPrefix("only.bar", id)).findAny(); .filter((id) -> findIdFromPrefix("only.bar", id)).findAny();
ConfigurationPropertiesBeanDescriptor descriptor = contextProperties.getBeans().get(key.get()); ConfigurationPropertiesBeanDescriptor descriptor = contextProperties.getBeans().get(key.get());
assertThat(descriptor.getPrefix()).isEqualTo("only.bar"); assertThat(descriptor.getPrefix()).isEqualTo("only.bar");
assertThat(descriptor.getProperties().get("name")).isEqualTo(value); assertThat(descriptor.getProperties()).containsEntry("name", value);
}); });
} }

@ -76,7 +76,7 @@ class ConfigurationPropertiesReportEndpointProxyTests {
.getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties(); .getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties();
Map<String, Object> properties = applicationProperties.getContexts().get(context.getId()).getBeans() Map<String, Object> properties = applicationProperties.getContexts().get(context.getId()).getBeans()
.values().stream().map(ConfigurationPropertiesBeanDescriptor::getProperties).findFirst().get(); .values().stream().map(ConfigurationPropertiesBeanDescriptor::getProperties).findFirst().get();
assertThat(properties.get("name")).isEqualTo("baz"); assertThat(properties).containsEntry("name", "baz");
}); });
} }

@ -71,7 +71,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
Map<String, Object> map = foo.getProperties(); Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull(); assertThat(map).isNotNull();
assertThat(map).hasSize(2); assertThat(map).hasSize(2);
assertThat(map.get("name")).isEqualTo("foo"); assertThat(map).containsEntry("name", "foo");
}); });
} }
@ -90,7 +90,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
Map<String, Object> map = foo.getProperties(); Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull(); assertThat(map).isNotNull();
assertThat(map).hasSize(2); assertThat(map).hasSize(2);
assertThat(((Map<String, Object>) map.get("bar")).get("name")).isEqualTo("foo"); assertThat(((Map<String, Object>) map.get("bar"))).containsEntry("name", "foo");
}); });
} }
@ -150,7 +150,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
Map<String, Object> map = fooProperties.getProperties(); Map<String, Object> map = fooProperties.getProperties();
assertThat(map).isNotNull(); assertThat(map).isNotNull();
assertThat(map).hasSize(3); assertThat(map).hasSize(3);
assertThat(((Map<String, Object>) map.get("map")).get("name")).isEqualTo("foo"); assertThat(((Map<String, Object>) map.get("map"))).containsEntry("name", "foo");
}); });
} }
@ -207,7 +207,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
Map<String, Object> map = foo.getProperties(); Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull(); assertThat(map).isNotNull();
assertThat(map).hasSize(3); assertThat(map).hasSize(3);
assertThat(map.get("address")).isEqualTo("192.168.1.10"); assertThat(map).containsEntry("address", "192.168.1.10");
}); });
} }

@ -105,12 +105,12 @@ class ConfigurationPropertiesReportEndpointTests {
Map<String, Object> nested = (Map<String, Object>) inputs.get("nested"); Map<String, Object> nested = (Map<String, Object>) inputs.get("nested");
Map<String, Object> name = (Map<String, Object>) nested.get("name"); Map<String, Object> name = (Map<String, Object>) nested.get("name");
Map<String, Object> counter = (Map<String, Object>) nested.get("counter"); Map<String, Object> counter = (Map<String, Object>) nested.get("counter");
assertThat(name.get("value")).isEqualTo("nested"); assertThat(name).containsEntry("value", "nested");
assertThat(name.get("origin")) assertThat(name).containsEntry("origin",
.isEqualTo("\"immutablenested.nested.name\" from property source \"test\""); "\"immutablenested.nested.name\" from property source \"test\"");
assertThat(counter.get("origin")) assertThat(counter).containsEntry("origin",
.isEqualTo("\"immutablenested.nested.counter\" from property source \"test\""); "\"immutablenested.nested.counter\" from property source \"test\"");
assertThat(counter.get("value")).isEqualTo("42"); assertThat(counter).containsEntry("value", "42");
})); }));
} }
@ -184,8 +184,8 @@ class ConfigurationPropertiesReportEndpointTests {
.withPropertyValues(String.format("data.size=%s", configSize)).run(assertProperties("data", .withPropertyValues(String.format("data.size=%s", configSize)).run(assertProperties("data",
(properties) -> assertThat(properties.get("size")).isEqualTo(stringifySize), (inputs) -> { (properties) -> assertThat(properties.get("size")).isEqualTo(stringifySize), (inputs) -> {
Map<String, Object> size = (Map<String, Object>) inputs.get("size"); Map<String, Object> size = (Map<String, Object>) inputs.get("size");
assertThat(size.get("value")).isEqualTo(configSize); assertThat(size).containsEntry("value", configSize);
assertThat(size.get("origin")).isEqualTo("\"data.size\" from property source \"test\""); assertThat(size).containsEntry("origin", "\"data.size\" from property source \"test\"");
})); }));
} }
@ -199,15 +199,15 @@ class ConfigurationPropertiesReportEndpointTests {
List<Object> list = (List<Object>) properties.get("listItems"); List<Object> list = (List<Object>) properties.get("listItems");
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
assertThat(item.get("somePassword")).isEqualTo("******"); assertThat(item).containsEntry("somePassword", "******");
}, (inputs) -> { }, (inputs) -> {
List<Object> list = (List<Object>) inputs.get("listItems"); List<Object> list = (List<Object>) inputs.get("listItems");
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
Map<String, Object> somePassword = (Map<String, Object>) item.get("somePassword"); Map<String, Object> somePassword = (Map<String, Object>) item.get("somePassword");
assertThat(somePassword.get("value")).isEqualTo("******"); assertThat(somePassword).containsEntry("value", "******");
assertThat(somePassword.get("origin")) assertThat(somePassword).containsEntry("origin",
.isEqualTo("\"sensible.listItems[0].some-password\" from property source \"test\""); "\"sensible.listItems[0].some-password\" from property source \"test\"");
})); }));
} }
@ -223,7 +223,7 @@ class ConfigurationPropertiesReportEndpointTests {
List<Object> list = listOfLists.get(0); List<Object> list = listOfLists.get(0);
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
assertThat(item.get("somePassword")).isEqualTo("******"); assertThat(item).containsEntry("somePassword", "******");
}, (inputs) -> { }, (inputs) -> {
assertThat(inputs.get("listOfListItems")).isInstanceOf(List.class); assertThat(inputs.get("listOfListItems")).isInstanceOf(List.class);
List<List<Object>> listOfLists = (List<List<Object>>) inputs.get("listOfListItems"); List<List<Object>> listOfLists = (List<List<Object>>) inputs.get("listOfListItems");
@ -232,8 +232,8 @@ class ConfigurationPropertiesReportEndpointTests {
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
Map<String, Object> somePassword = (Map<String, Object>) item.get("somePassword"); Map<String, Object> somePassword = (Map<String, Object>) item.get("somePassword");
assertThat(somePassword.get("value")).isEqualTo("******"); assertThat(somePassword).containsEntry("value", "******");
assertThat(somePassword.get("origin")).isEqualTo( assertThat(somePassword).containsEntry("origin",
"\"sensible.listOfListItems[0][0].some-password\" from property source \"test\""); "\"sensible.listOfListItems[0][0].some-password\" from property source \"test\"");
})); }));
} }
@ -243,8 +243,8 @@ class ConfigurationPropertiesReportEndpointTests {
new ApplicationContextRunner().withUserConfiguration(CustomSanitizingEndpointConfig.class, new ApplicationContextRunner().withUserConfiguration(CustomSanitizingEndpointConfig.class,
SanitizingFunctionConfiguration.class, TestPropertiesConfiguration.class) SanitizingFunctionConfiguration.class, TestPropertiesConfiguration.class)
.run(assertProperties("test", (properties) -> { .run(assertProperties("test", (properties) -> {
assertThat(properties.get("dbPassword")).isEqualTo("$$$"); assertThat(properties).containsEntry("dbPassword", "$$$");
assertThat(properties.get("myTestProperty")).isEqualTo("$$$"); assertThat(properties).containsEntry("myTestProperty", "$$$");
})); }));
} }
@ -254,8 +254,8 @@ class ConfigurationPropertiesReportEndpointTests {
.withUserConfiguration(CustomSanitizingEndpointConfig.class, .withUserConfiguration(CustomSanitizingEndpointConfig.class,
PropertySourceBasedSanitizingFunctionConfiguration.class, TestPropertiesConfiguration.class) PropertySourceBasedSanitizingFunctionConfiguration.class, TestPropertiesConfiguration.class)
.withPropertyValues("test.my-test-property=abcde").run(assertProperties("test", (properties) -> { .withPropertyValues("test.my-test-property=abcde").run(assertProperties("test", (properties) -> {
assertThat(properties.get("dbPassword")).isEqualTo("123456"); assertThat(properties).containsEntry("dbPassword", "123456");
assertThat(properties.get("myTestProperty")).isEqualTo("$$$"); assertThat(properties).containsEntry("myTestProperty", "$$$");
})); }));
} }
@ -270,15 +270,15 @@ class ConfigurationPropertiesReportEndpointTests {
List<Object> list = (List<Object>) properties.get("listItems"); List<Object> list = (List<Object>) properties.get("listItems");
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
assertThat(item.get("custom")).isEqualTo("$$$"); assertThat(item).containsEntry("custom", "$$$");
}, (inputs) -> { }, (inputs) -> {
List<Object> list = (List<Object>) inputs.get("listItems"); List<Object> list = (List<Object>) inputs.get("listItems");
assertThat(list).hasSize(1); assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0); Map<String, Object> item = (Map<String, Object>) list.get(0);
Map<String, Object> somePassword = (Map<String, Object>) item.get("custom"); Map<String, Object> somePassword = (Map<String, Object>) item.get("custom");
assertThat(somePassword.get("value")).isEqualTo("$$$"); assertThat(somePassword).containsEntry("value", "$$$");
assertThat(somePassword.get("origin")) assertThat(somePassword).containsEntry("origin",
.isEqualTo("\"sensible.listItems[0].custom\" from property source \"test\""); "\"sensible.listItems[0].custom\" from property source \"test\"");
})); }));
} }
@ -287,8 +287,8 @@ class ConfigurationPropertiesReportEndpointTests {
new ApplicationContextRunner() new ApplicationContextRunner()
.withUserConfiguration(EndpointConfigWithShowAlways.class, TestPropertiesConfiguration.class) .withUserConfiguration(EndpointConfigWithShowAlways.class, TestPropertiesConfiguration.class)
.run(assertProperties("test", (properties) -> { .run(assertProperties("test", (properties) -> {
assertThat(properties.get("dbPassword")).isEqualTo("123456"); assertThat(properties).containsEntry("dbPassword", "123456");
assertThat(properties.get("myTestProperty")).isEqualTo("654321"); assertThat(properties).containsEntry("myTestProperty", "654321");
})); }));
} }
@ -297,8 +297,8 @@ class ConfigurationPropertiesReportEndpointTests {
new ApplicationContextRunner() new ApplicationContextRunner()
.withUserConfiguration(EndpointConfigWithShowNever.class, TestPropertiesConfiguration.class) .withUserConfiguration(EndpointConfigWithShowNever.class, TestPropertiesConfiguration.class)
.run(assertProperties("test", (properties) -> { .run(assertProperties("test", (properties) -> {
assertThat(properties.get("dbPassword")).isEqualTo("******"); assertThat(properties).containsEntry("dbPassword", "******");
assertThat(properties.get("myTestProperty")).isEqualTo("******"); assertThat(properties).containsEntry("myTestProperty", "******");
})); }));
} }

@ -80,7 +80,7 @@ class EndpointIdTests {
// Ideally we wouldn't support this but there are existing endpoints using the // Ideally we wouldn't support this but there are existing endpoints using the
// pattern. See gh-14773 // pattern. See gh-14773
EndpointId endpointId = EndpointId.of("foo.bar"); EndpointId endpointId = EndpointId.of("foo.bar");
assertThat(endpointId.toString()).isEqualTo("foo.bar"); assertThat(endpointId).hasToString("foo.bar");
} }
@Test @Test
@ -88,7 +88,7 @@ class EndpointIdTests {
// Ideally we wouldn't support this but there are existing endpoints using the // Ideally we wouldn't support this but there are existing endpoints using the
// pattern. See gh-14773 // pattern. See gh-14773
EndpointId endpointId = EndpointId.of("foo-bar"); EndpointId endpointId = EndpointId.of("foo-bar");
assertThat(endpointId.toString()).isEqualTo("foo-bar"); assertThat(endpointId).hasToString("foo-bar");
} }
@Test @Test
@ -102,21 +102,21 @@ class EndpointIdTests {
@Test @Test
void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) { void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) {
EndpointId endpointId = migrateLegacyName("one.two.three"); EndpointId endpointId = migrateLegacyName("one.two.three");
assertThat(endpointId.toString()).isEqualTo("onetwothree"); assertThat(endpointId).hasToString("onetwothree");
assertThat(output).doesNotContain("contains invalid characters"); assertThat(output).doesNotContain("contains invalid characters");
} }
@Test @Test
void ofWhenMigratingLegacyNameRemovesHyphens(CapturedOutput output) { void ofWhenMigratingLegacyNameRemovesHyphens(CapturedOutput output) {
EndpointId endpointId = migrateLegacyName("one-two-three"); EndpointId endpointId = migrateLegacyName("one-two-three");
assertThat(endpointId.toString()).isEqualTo("onetwothree"); assertThat(endpointId).hasToString("onetwothree");
assertThat(output).doesNotContain("contains invalid characters"); assertThat(output).doesNotContain("contains invalid characters");
} }
@Test @Test
void ofWhenMigratingLegacyNameRemovesMixOfDashAndDot(CapturedOutput output) { void ofWhenMigratingLegacyNameRemovesMixOfDashAndDot(CapturedOutput output) {
EndpointId endpointId = migrateLegacyName("one.two-three"); EndpointId endpointId = migrateLegacyName("one.two-three");
assertThat(endpointId.toString()).isEqualTo("onetwothree"); assertThat(endpointId).hasToString("onetwothree");
assertThat(output).doesNotContain("contains invalid characters"); assertThat(output).doesNotContain("contains invalid characters");
} }
@ -135,7 +135,7 @@ class EndpointIdTests {
EndpointId four = EndpointId.of("foo.bar1"); EndpointId four = EndpointId.of("foo.bar1");
EndpointId five = EndpointId.of("barfoo1"); EndpointId five = EndpointId.of("barfoo1");
EndpointId six = EndpointId.of("foobar2"); EndpointId six = EndpointId.of("foobar2");
assertThat(one.hashCode()).isEqualTo(two.hashCode()); assertThat(one).hasSameHashCodeAs(two);
assertThat(one).isEqualTo(one).isEqualTo(two).isEqualTo(three).isEqualTo(four).isNotEqualTo(five) assertThat(one).isEqualTo(one).isEqualTo(two).isEqualTo(three).isEqualTo(four).isNotEqualTo(five)
.isNotEqualTo(six); .isNotEqualTo(six);
} }
@ -147,7 +147,7 @@ class EndpointIdTests {
@Test @Test
void toStringReturnsString() { void toStringReturnsString() {
assertThat(EndpointId.of("fooBar").toString()).isEqualTo("fooBar"); assertThat(EndpointId.of("fooBar")).hasToString("fooBar");
} }
@Test @Test

@ -61,7 +61,7 @@ class ProducibleOperationArgumentResolverTests {
@Test @Test
void whenNothingIsAcceptableThenNullIsReturned() { void whenNothingIsAcceptableThenNullIsReturned() {
assertThat(resolve(acceptHeader("image/png"))).isEqualTo(null); assertThat(resolve(acceptHeader("image/png"))).isNull();
} }
@Test @Test

@ -86,7 +86,7 @@ class OperationMethodParametersTests {
void getParameterCountShouldReturnParameterCount() { void getParameterCountShouldReturnParameterCount() {
OperationMethodParameters parameters = new OperationMethodParameters(this.exampleMethod, OperationMethodParameters parameters = new OperationMethodParameters(this.exampleMethod,
new DefaultParameterNameDiscoverer()); new DefaultParameterNameDiscoverer());
assertThat(parameters.getParameterCount()).isEqualTo(1); assertThat(parameters.getParameterCount()).isOne();
} }
@Test @Test

@ -64,7 +64,7 @@ class OperationMethodTests {
void getParametersShouldReturnParameters() { void getParametersShouldReturnParameters() {
OperationMethod operationMethod = new OperationMethod(this.exampleMethod, OperationType.READ); OperationMethod operationMethod = new OperationMethod(this.exampleMethod, OperationType.READ);
OperationParameters parameters = operationMethod.getParameters(); OperationParameters parameters = operationMethod.getParameters();
assertThat(parameters.getParameterCount()).isEqualTo(1); assertThat(parameters.getParameterCount()).isOne();
assertThat(parameters.iterator().next().getName()).isEqualTo("name"); assertThat(parameters.iterator().next().getName()).isEqualTo("name");
} }

@ -54,29 +54,29 @@ class MBeanInfoFactoryTests {
MBeanOperationInfo operationInfo = info.getOperations()[0]; MBeanOperationInfo operationInfo = info.getOperations()[0];
assertThat(operationInfo.getName()).isEqualTo("testOperation"); assertThat(operationInfo.getName()).isEqualTo("testOperation");
assertThat(operationInfo.getReturnType()).isEqualTo(String.class.getName()); assertThat(operationInfo.getReturnType()).isEqualTo(String.class.getName());
assertThat(operationInfo.getImpact()).isEqualTo(MBeanOperationInfo.INFO); assertThat(operationInfo.getImpact()).isZero();
assertThat(operationInfo.getSignature()).hasSize(0); assertThat(operationInfo.getSignature()).isEmpty();
} }
@Test @Test
void getMBeanInfoWhenReadOperationShouldHaveInfoImpact() { void getMBeanInfoWhenReadOperationShouldHaveInfoImpact() {
MBeanInfo info = this.factory MBeanInfo info = this.factory
.getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.READ))); .getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.READ)));
assertThat(info.getOperations()[0].getImpact()).isEqualTo(MBeanOperationInfo.INFO); assertThat(info.getOperations()[0].getImpact()).isZero();
} }
@Test @Test
void getMBeanInfoWhenWriteOperationShouldHaveActionImpact() { void getMBeanInfoWhenWriteOperationShouldHaveActionImpact() {
MBeanInfo info = this.factory MBeanInfo info = this.factory
.getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.WRITE))); .getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.WRITE)));
assertThat(info.getOperations()[0].getImpact()).isEqualTo(MBeanOperationInfo.ACTION); assertThat(info.getOperations()[0].getImpact()).isOne();
} }
@Test @Test
void getMBeanInfoWhenDeleteOperationShouldHaveActionImpact() { void getMBeanInfoWhenDeleteOperationShouldHaveActionImpact() {
MBeanInfo info = this.factory MBeanInfo info = this.factory
.getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.DELETE))); .getMBeanInfo(new TestExposableJmxEndpoint(new TestJmxOperation(OperationType.DELETE)));
assertThat(info.getOperations()[0].getImpact()).isEqualTo(MBeanOperationInfo.ACTION); assertThat(info.getOperations()[0].getImpact()).isOne();
} }
@Test @Test

@ -29,12 +29,12 @@ class EndpointMappingTests {
@Test @Test
void normalizationTurnsASlashIntoAnEmptyString() { void normalizationTurnsASlashIntoAnEmptyString() {
assertThat(new EndpointMapping("/").getPath()).isEqualTo(""); assertThat(new EndpointMapping("/").getPath()).isEmpty();
} }
@Test @Test
void normalizationLeavesAnEmptyStringAsIs() { void normalizationLeavesAnEmptyStringAsIs() {
assertThat(new EndpointMapping("").getPath()).isEqualTo(""); assertThat(new EndpointMapping("").getPath()).isEmpty();
} }
@Test @Test

@ -351,7 +351,7 @@ abstract class HealthEndpointSupportTests<S extends HealthEndpointSupport<C, T>,
Collections.singletonMap("testGroup", testGroup)); Collections.singletonMap("testGroup", testGroup));
HealthResult<T> result = create(this.registry, groups).getHealth(ApiVersion.V3, WebServerNamespace.SERVER, HealthResult<T> result = create(this.registry, groups).getHealth(ApiVersion.V3, WebServerNamespace.SERVER,
SecurityContext.NONE, false, "healthz", "test"); SecurityContext.NONE, false, "healthz", "test");
assertThat(result).isEqualTo(null); assertThat(result).isNull();
} }
protected final S create(R registry, HealthEndpointGroups groups) { protected final S create(R registry, HealthEndpointGroups groups) {

@ -65,8 +65,8 @@ class HealthTests {
assertThat(h1).isEqualTo(h1); assertThat(h1).isEqualTo(h1);
assertThat(h1).isEqualTo(h2); assertThat(h1).isEqualTo(h2);
assertThat(h1).isNotEqualTo(h3); assertThat(h1).isNotEqualTo(h3);
assertThat(h1.hashCode()).isEqualTo(h1.hashCode()); assertThat(h1).hasSameHashCodeAs(h1);
assertThat(h1.hashCode()).isEqualTo(h2.hashCode()); assertThat(h1).hasSameHashCodeAs(h2);
assertThat(h1.hashCode()).isNotEqualTo(h3.hashCode()); assertThat(h1.hashCode()).isNotEqualTo(h3.hashCode());
} }

@ -59,7 +59,7 @@ class StatusTests {
Status two = new Status("spring", "framework"); Status two = new Status("spring", "framework");
Status three = new Status("spock", "framework"); Status three = new Status("spock", "framework");
assertThat(one).isEqualTo(one).isEqualTo(two).isNotEqualTo(three); assertThat(one).isEqualTo(one).isEqualTo(two).isNotEqualTo(three);
assertThat(one.hashCode()).isEqualTo(two.hashCode()); assertThat(one).hasSameHashCodeAs(two);
} }
@Test @Test

@ -47,7 +47,7 @@ class InfluxDbHealthIndicatorTests {
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb); InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo("0.9"); assertThat(health.getDetails()).containsEntry("version", "0.9");
then(influxDb).should().ping(); then(influxDb).should().ping();
} }

@ -42,7 +42,7 @@ class EnvironmentInfoContributorTests {
Info actual = contributeFrom(this.environment); Info actual = contributeFrom(this.environment);
assertThat(actual.get("app", String.class)).isEqualTo("my app"); assertThat(actual.get("app", String.class)).isEqualTo("my app");
assertThat(actual.get("version", String.class)).isEqualTo("1.0.0"); assertThat(actual.get("version", String.class)).isEqualTo("1.0.0");
assertThat(actual.getDetails().size()).isEqualTo(2); assertThat(actual.getDetails()).hasSize(2);
} }
@Test @Test

@ -64,7 +64,7 @@ class GitInfoContributorTests {
Map<String, Object> content = contributor.generateContent(); Map<String, Object> content = contributor.generateContent();
assertThat(content.get("commit")).isInstanceOf(Map.class); assertThat(content.get("commit")).isInstanceOf(Map.class);
Map<String, Object> commit = (Map<String, Object>) content.get("commit"); Map<String, Object> commit = (Map<String, Object>) content.get("commit");
assertThat(commit.get("id")).isEqualTo("8e29a0b"); assertThat(commit).containsEntry("id", "8e29a0b");
} }
@Test @Test
@ -80,8 +80,8 @@ class GitInfoContributorTests {
Map<String, Object> commit = (Map<String, Object>) content.get("commit"); Map<String, Object> commit = (Map<String, Object>) content.get("commit");
assertThat(commit.get("id")).isInstanceOf(Map.class); assertThat(commit.get("id")).isInstanceOf(Map.class);
Map<String, Object> id = (Map<String, Object>) commit.get("id"); Map<String, Object> id = (Map<String, Object>) commit.get("id");
assertThat(id.get("full")).isEqualTo("1b3cec34f7ca0a021244452f2cae07a80497a7c7"); assertThat(id).containsEntry("full", "1b3cec34f7ca0a021244452f2cae07a80497a7c7");
assertThat(id.get("abbrev")).isEqualTo("1b3cec3"); assertThat(id).containsEntry("abbrev", "1b3cec3");
} }
@Test @Test

@ -105,7 +105,7 @@ class DataSourceHealthIndicatorTests {
given(dataSource.getConnection()).willReturn(connection); given(dataSource.getConnection()).willReturn(connection);
this.indicator.setDataSource(dataSource); this.indicator.setDataSource(dataSource);
Health health = this.indicator.health(); Health health = this.indicator.health();
assertThat(health.getDetails().get("database")).isNotNull(); assertThat(health.getDetails()).containsKey("database");
then(connection).should(times(2)).close(); then(connection).should(times(2)).close();
} }

@ -52,7 +52,7 @@ class JmsHealthIndicatorTests {
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory); JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health(); Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("provider")).isEqualTo("JMS test provider"); assertThat(health.getDetails()).containsEntry("provider", "JMS test provider");
then(connection).should().close(); then(connection).should().close();
} }
@ -63,7 +63,7 @@ class JmsHealthIndicatorTests {
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory); JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health(); Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("provider")).isNull(); assertThat(health.getDetails()).doesNotContainKey("provider");
} }
@Test @Test
@ -77,7 +77,7 @@ class JmsHealthIndicatorTests {
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory); JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health(); Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("provider")).isNull(); assertThat(health.getDetails()).doesNotContainKey("provider");
then(connection).should().close(); then(connection).should().close();
} }
@ -93,7 +93,7 @@ class JmsHealthIndicatorTests {
JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory); JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
Health health = indicator.health(); Health health = indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("provider")).isNull(); assertThat(health.getDetails()).doesNotContainKey("provider");
} }
@Test @Test

@ -45,7 +45,7 @@ class LdapHealthIndicatorTests {
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate); LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo("3"); assertThat(health.getDetails()).containsEntry("version", "3");
then(ldapTemplate).should().executeReadOnly((ContextExecutor<String>) any()); then(ldapTemplate).should().executeReadOnly((ContextExecutor<String>) any());
} }

@ -66,7 +66,7 @@ class MailHealthIndicatorTests {
given(this.mailSender.getProtocol()).willReturn("success"); given(this.mailSender.getProtocol()).willReturn("success");
Health health = this.indicator.health(); Health health = this.indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("location")).isEqualTo("smtp.acme.org:25"); assertThat(health.getDetails()).containsEntry("location", "smtp.acme.org:25");
} }
@Test @Test
@ -74,10 +74,10 @@ class MailHealthIndicatorTests {
willThrow(new MessagingException("A test exception")).given(this.mailSender).testConnection(); willThrow(new MessagingException("A test exception")).given(this.mailSender).testConnection();
Health health = this.indicator.health(); Health health = this.indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("location")).isEqualTo("smtp.acme.org:25"); assertThat(health.getDetails()).containsEntry("location", "smtp.acme.org:25");
Object errorMessage = health.getDetails().get("error"); Object errorMessage = health.getDetails().get("error");
assertThat(errorMessage).isNotNull(); assertThat(errorMessage).isNotNull();
assertThat(errorMessage.toString().contains("A test exception")).isTrue(); assertThat(errorMessage.toString()).contains("A test exception");
} }
static class SuccessTransport extends Transport { static class SuccessTransport extends Transport {

@ -36,7 +36,7 @@ class ThreadDumpEndpointTests {
@Test @Test
void dumpThreads() { void dumpThreads() {
assertThat(new ThreadDumpEndpoint().threadDump().getThreads().size()).isGreaterThan(0); assertThat(new ThreadDumpEndpoint().threadDump().getThreads()).isNotEmpty();
} }
@Test @Test

@ -86,7 +86,7 @@ class MetricsRepositoryMethodInvocationListenerTests {
} }
private void assertMetricsContainsTag(String tagKey, String tagValue) { private void assertMetricsContainsTag(String tagKey, String tagValue) {
assertThat(this.registry.get(REQUEST_METRICS_NAME).tag(tagKey, tagValue).timer().count()).isEqualTo(1); assertThat(this.registry.get(REQUEST_METRICS_NAME).tag(tagKey, tagValue).timer().count()).isOne();
} }
private RepositoryMethodInvocation createInvocation(Class<?> repositoryInterface) { private RepositoryMethodInvocation createInvocation(Class<?> repositoryInterface) {

@ -46,7 +46,7 @@ class MongoHealthIndicatorTests {
MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate); MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("maxWireVersion")).isEqualTo(10); assertThat(health.getDetails()).containsEntry("maxWireVersion", 10);
then(commandResult).should().getInteger("maxWireVersion"); then(commandResult).should().getInteger("maxWireVersion");
then(mongoTemplate).should().executeCommand("{ isMaster: 1 }"); then(mongoTemplate).should().executeCommand("{ isMaster: 1 }");
} }

@ -50,7 +50,7 @@ class MongoReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("maxWireVersion"); assertThat(h.getDetails()).containsOnlyKeys("maxWireVersion");
assertThat(h.getDetails().get("maxWireVersion")).isEqualTo(10); assertThat(h.getDetails()).containsEntry("maxWireVersion", 10);
}).verifyComplete(); }).verifyComplete();
} }
@ -65,7 +65,7 @@ class MongoReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN); assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails()).containsOnlyKeys("error"); assertThat(h.getDetails()).containsOnlyKeys("error");
assertThat(h.getDetails().get("error")).isEqualTo(MongoException.class.getName() + ": Connection failed"); assertThat(h.getDetails()).containsEntry("error", MongoException.class.getName() + ": Connection failed");
}).verifyComplete(); }).verifyComplete();
} }

@ -59,7 +59,7 @@ class RedisHealthIndicatorTests {
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection); RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo("2.8.9"); assertThat(health.getDetails()).containsEntry("version", "2.8.9");
} }
@Test @Test
@ -80,9 +80,9 @@ class RedisHealthIndicatorTests {
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory); RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails()).containsEntry("cluster_size", 4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L); assertThat(health.getDetails()).containsEntry("slots_up", 4L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L); assertThat(health.getDetails()).containsEntry("slots_fail", 0L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection(); then(redisConnectionFactory).should(atLeastOnce()).getConnection();
} }
@ -92,9 +92,9 @@ class RedisHealthIndicatorTests {
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory); RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails()).containsEntry("cluster_size", 4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L); assertThat(health.getDetails()).containsEntry("slots_up", 4L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L); assertThat(health.getDetails()).containsEntry("slots_fail", 0L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection(); then(redisConnectionFactory).should(atLeastOnce()).getConnection();
} }
@ -104,9 +104,9 @@ class RedisHealthIndicatorTests {
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory); RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health(); Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(health.getDetails()).containsEntry("cluster_size", 4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(3L); assertThat(health.getDetails()).containsEntry("slots_up", 3L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(1L); assertThat(health.getDetails()).containsEntry("slots_fail", 1L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection(); then(redisConnectionFactory).should(atLeastOnce()).getConnection();
} }

@ -62,7 +62,7 @@ class RedisReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version"); assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails().get("version")).isEqualTo("2.8.9"); assertThat(h.getDetails()).containsEntry("version", "2.8.9");
}).verifyComplete(); }).verifyComplete();
then(redisConnection).should().closeLater(); then(redisConnection).should().closeLater();
} }
@ -74,9 +74,9 @@ class RedisReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health(); Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(h.getDetails()).containsEntry("cluster_size", 4L);
assertThat(h.getDetails().get("slots_up")).isEqualTo(4L); assertThat(h.getDetails()).containsEntry("slots_up", 4L);
assertThat(h.getDetails().get("slots_fail")).isEqualTo(0L); assertThat(h.getDetails()).containsEntry("slots_fail", 0L);
}).verifyComplete(); }).verifyComplete();
then(redisConnectionFactory.getReactiveConnection()).should().closeLater(); then(redisConnectionFactory.getReactiveConnection()).should().closeLater();
} }
@ -88,9 +88,9 @@ class RedisReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health(); Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails().get("cluster_size")).isEqualTo(4L); assertThat(h.getDetails()).containsEntry("cluster_size", 4L);
assertThat(h.getDetails().get("slots_up")).isEqualTo(4L); assertThat(h.getDetails()).containsEntry("slots_up", 4L);
assertThat(h.getDetails().get("slots_fail")).isEqualTo(0L); assertThat(h.getDetails()).containsEntry("slots_fail", 0L);
}).verifyComplete(); }).verifyComplete();
} }
@ -101,8 +101,8 @@ class RedisReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health(); Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> { StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN); assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails().get("slots_up")).isEqualTo(3L); assertThat(h.getDetails()).containsEntry("slots_up", 3L);
assertThat(h.getDetails().get("slots_fail")).isEqualTo(1L); assertThat(h.getDetails()).containsEntry("slots_fail", 1L);
}).verifyComplete(); }).verifyComplete();
} }

@ -93,7 +93,7 @@ class ScheduledTasksEndpointTests {
assertThat(tasks.getFixedDelay()).hasSize(1); assertThat(tasks.getFixedDelay()).hasSize(1);
FixedDelayTaskDescriptor description = (FixedDelayTaskDescriptor) tasks.getFixedDelay().get(0); FixedDelayTaskDescriptor description = (FixedDelayTaskDescriptor) tasks.getFixedDelay().get(0);
assertThat(description.getInitialDelay()).isEqualTo(2); assertThat(description.getInitialDelay()).isEqualTo(2);
assertThat(description.getInterval()).isEqualTo(1); assertThat(description.getInterval()).isOne();
assertThat(description.getRunnable().getTarget()) assertThat(description.getRunnable().getTarget())
.isEqualTo(FixedDelayScheduledMethod.class.getName() + ".fixedDelay"); .isEqualTo(FixedDelayScheduledMethod.class.getName() + ".fixedDelay");
}); });

@ -64,11 +64,11 @@ class DiskSpaceHealthIndicatorTests {
given(this.fileMock.getAbsolutePath()).willReturn("/absolute-path"); given(this.fileMock.getAbsolutePath()).willReturn("/absolute-path");
Health health = this.healthIndicator.health(); Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD.toBytes()); assertThat(health.getDetails()).containsEntry("threshold", THRESHOLD.toBytes());
assertThat(health.getDetails().get("free")).isEqualTo(freeSpace); assertThat(health.getDetails()).containsEntry("free", freeSpace);
assertThat(health.getDetails().get("total")).isEqualTo(TOTAL_SPACE.toBytes()); assertThat(health.getDetails()).containsEntry("total", TOTAL_SPACE.toBytes());
assertThat(health.getDetails().get("path")).isEqualTo("/absolute-path"); assertThat(health.getDetails()).containsEntry("path", "/absolute-path");
assertThat(health.getDetails().get("exists")).isEqualTo(true); assertThat(health.getDetails()).containsEntry("exists", true);
} }
@Test @Test
@ -80,20 +80,20 @@ class DiskSpaceHealthIndicatorTests {
given(this.fileMock.getAbsolutePath()).willReturn("/absolute-path"); given(this.fileMock.getAbsolutePath()).willReturn("/absolute-path");
Health health = this.healthIndicator.health(); Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD.toBytes()); assertThat(health.getDetails()).containsEntry("threshold", THRESHOLD.toBytes());
assertThat(health.getDetails().get("free")).isEqualTo(freeSpace); assertThat(health.getDetails()).containsEntry("free", freeSpace);
assertThat(health.getDetails().get("total")).isEqualTo(TOTAL_SPACE.toBytes()); assertThat(health.getDetails()).containsEntry("total", TOTAL_SPACE.toBytes());
assertThat(health.getDetails().get("path")).isEqualTo("/absolute-path"); assertThat(health.getDetails()).containsEntry("path", "/absolute-path");
assertThat(health.getDetails().get("exists")).isEqualTo(true); assertThat(health.getDetails()).containsEntry("exists", true);
} }
@Test @Test
void whenPathDoesNotExistDiskSpaceIsDown() { void whenPathDoesNotExistDiskSpaceIsDown() {
Health health = new DiskSpaceHealthIndicator(new File("does/not/exist"), THRESHOLD).health(); Health health = new DiskSpaceHealthIndicator(new File("does/not/exist"), THRESHOLD).health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("free")).isEqualTo(0L); assertThat(health.getDetails()).containsEntry("free", 0L);
assertThat(health.getDetails().get("total")).isEqualTo(0L); assertThat(health.getDetails()).containsEntry("total", 0L);
assertThat(health.getDetails().get("exists")).isEqualTo(false); assertThat(health.getDetails()).containsEntry("exists", false);
} }
} }

@ -115,7 +115,7 @@ class HttpExchangesFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setServerName("<script>alert(document.domain)</script>"); request.setServerName("<script>alert(document.domain)</script>");
this.filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); this.filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
assertThat(this.repository.findAll()).hasSize(0); assertThat(this.repository.findAll()).isEmpty();
} }
} }

@ -62,7 +62,7 @@ class RecordableServletHttpRequestTests {
private void validate(String expectedUri) { private void validate(String expectedUri) {
RecordableServletHttpRequest sourceRequest = new RecordableServletHttpRequest(this.request); RecordableServletHttpRequest sourceRequest = new RecordableServletHttpRequest(this.request);
assertThat(sourceRequest.getUri().toString()).isEqualTo(expectedUri); assertThat(sourceRequest.getUri()).hasToString(expectedUri);
} }
} }

@ -75,7 +75,7 @@ class AbstractDependsOnBeanFactoryPostProcessorTests {
@Test @Test
void postProcessorHasADefaultOrderOfZero() { void postProcessorHasADefaultOrderOfZero() {
assertThat(new FooDependsOnBarTypePostProcessor().getOrder()).isEqualTo(0); assertThat(new FooDependsOnBarTypePostProcessor().getOrder()).isZero();
} }
private void assertThatFooDependsOnBar(AssertableApplicationContext context) { private void assertThatFooDependsOnBar(AssertableApplicationContext context) {

@ -125,7 +125,7 @@ class ImportAutoConfigurationImportSelectorTests {
Set<Object> set2 = this.importSelector Set<Object> set2 = this.importSelector
.determineImports(getAnnotationMetadata(ImportMetaAutoConfigurationWithUnrelatedTwo.class)); .determineImports(getAnnotationMetadata(ImportMetaAutoConfigurationWithUnrelatedTwo.class));
assertThat(set1).isEqualTo(set2); assertThat(set1).isEqualTo(set2);
assertThat(set1.hashCode()).isEqualTo(set2.hashCode()); assertThat(set1).hasSameHashCodeAs(set2);
} }
@Test @Test
@ -153,7 +153,7 @@ class ImportAutoConfigurationImportSelectorTests {
Set<Object> set2 = this.importSelector Set<Object> set2 = this.importSelector
.determineImports(getAnnotationMetadata(ImportMetaAutoConfigurationExcludeWithUnrelatedTwo.class)); .determineImports(getAnnotationMetadata(ImportMetaAutoConfigurationExcludeWithUnrelatedTwo.class));
assertThat(set1).isEqualTo(set2); assertThat(set1).isEqualTo(set2);
assertThat(set1.hashCode()).isEqualTo(set2.hashCode()); assertThat(set1).hasSameHashCodeAs(set2);
} }
@Test @Test

@ -39,28 +39,28 @@ class SpringBootApplicationTests {
void proxyBeanMethodsIsEnabledByDefault() { void proxyBeanMethodsIsEnabledByDefault() {
AnnotationAttributes attributes = AnnotatedElementUtils AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(DefaultSpringBootApplication.class, Configuration.class); .getMergedAnnotationAttributes(DefaultSpringBootApplication.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true); assertThat(attributes).containsEntry("proxyBeanMethods", true);
} }
@Test @Test
void proxyBeanMethodsCanBeDisabled() { void proxyBeanMethodsCanBeDisabled() {
AnnotationAttributes attributes = AnnotatedElementUtils AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(NoBeanMethodProxyingSpringBootApplication.class, Configuration.class); .getMergedAnnotationAttributes(NoBeanMethodProxyingSpringBootApplication.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false); assertThat(attributes).containsEntry("proxyBeanMethods", false);
} }
@Test @Test
void nameGeneratorDefaultToBeanNameGenerator() { void nameGeneratorDefaultToBeanNameGenerator() {
AnnotationAttributes attributes = AnnotatedElementUtils AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(DefaultSpringBootApplication.class, ComponentScan.class); .getMergedAnnotationAttributes(DefaultSpringBootApplication.class, ComponentScan.class);
assertThat(attributes.get("nameGenerator")).isEqualTo(BeanNameGenerator.class); assertThat(attributes).containsEntry("nameGenerator", BeanNameGenerator.class);
} }
@Test @Test
void nameGeneratorCanBeSpecified() { void nameGeneratorCanBeSpecified() {
AnnotationAttributes attributes = AnnotatedElementUtils AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(CustomNameGeneratorConfiguration.class, ComponentScan.class); .getMergedAnnotationAttributes(CustomNameGeneratorConfiguration.class, ComponentScan.class);
assertThat(attributes.get("nameGenerator")).isEqualTo(TestBeanNameGenerator.class); assertThat(attributes).containsEntry("nameGenerator", TestBeanNameGenerator.class);
} }
@SpringBootApplication @SpringBootApplication

@ -255,7 +255,7 @@ class BatchAutoConfigurationTests {
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class); PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
// It's a lazy proxy, but it does render its target if you ask for // It's a lazy proxy, but it does render its target if you ask for
// toString(): // toString():
assertThat(transactionManager.toString().contains("JpaTransactionManager")).isTrue(); assertThat(transactionManager.toString()).contains("JpaTransactionManager");
assertThat(context).hasSingleBean(EntityManagerFactory.class); assertThat(context).hasSingleBean(EntityManagerFactory.class);
// Ensure the JobRepository can be used (no problem with isolation // Ensure the JobRepository can be used (no problem with isolation
// level) // level)

@ -35,7 +35,7 @@ class JobExecutionExitCodeGeneratorTests {
@Test @Test
void testExitCodeForRunning() { void testExitCodeForRunning() {
this.generator.onApplicationEvent(new JobExecutionEvent(new JobExecution(0L))); this.generator.onApplicationEvent(new JobExecutionEvent(new JobExecution(0L)));
assertThat(this.generator.getExitCode()).isEqualTo(1); assertThat(this.generator.getExitCode()).isOne();
} }
@Test @Test
@ -43,7 +43,7 @@ class JobExecutionExitCodeGeneratorTests {
JobExecution execution = new JobExecution(0L); JobExecution execution = new JobExecution(0L);
execution.setStatus(BatchStatus.COMPLETED); execution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution)); this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isEqualTo(0); assertThat(this.generator.getExitCode()).isZero();
} }
@Test @Test

@ -72,7 +72,7 @@ abstract class AbstractCacheAutoConfigurationTests {
assertThat(value.cacheManager).isNull(); assertThat(value.cacheManager).isNull();
} }
}); });
assertThat(expected).hasSize(0); assertThat(expected).isEmpty();
}; };
} }

@ -696,7 +696,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
Cache foo = manager.getCache("foo"); Cache foo = manager.getCache("foo");
foo.get("1"); foo.get("1");
// See next tests: no spec given so stats should be disabled // See next tests: no spec given so stats should be disabled
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(0L); assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isZero();
}); });
} }
@ -750,7 +750,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
assertThat(manager.getCacheNames()).containsOnly("foo", "bar"); assertThat(manager.getCacheNames()).containsOnly("foo", "bar");
Cache foo = manager.getCache("foo"); Cache foo = manager.getCache("foo");
foo.get("1"); foo.get("1");
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(1L); assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isOne();
} }
private CouchbaseCacheConfiguration getDefaultCouchbaseCacheConfiguration(CouchbaseCacheManager cacheManager) { private CouchbaseCacheConfiguration getDefaultCouchbaseCacheConfiguration(CouchbaseCacheManager cacheManager) {

@ -56,14 +56,14 @@ class CacheManagerCustomizersTests {
list.add(new TestConcurrentMapCacheManagerCustomizer()); list.add(new TestConcurrentMapCacheManagerCustomizer());
CacheManagerCustomizers customizers = new CacheManagerCustomizers(list); CacheManagerCustomizers customizers = new CacheManagerCustomizers(list);
customizers.customize(mock(CacheManager.class)); customizers.customize(mock(CacheManager.class));
assertThat(list.get(0).getCount()).isEqualTo(1); assertThat(list.get(0).getCount()).isOne();
assertThat(list.get(1).getCount()).isEqualTo(0); assertThat(list.get(1).getCount()).isZero();
customizers.customize(mock(ConcurrentMapCacheManager.class)); customizers.customize(mock(ConcurrentMapCacheManager.class));
assertThat(list.get(0).getCount()).isEqualTo(2); assertThat(list.get(0).getCount()).isEqualTo(2);
assertThat(list.get(1).getCount()).isEqualTo(1); assertThat(list.get(1).getCount()).isOne();
customizers.customize(mock(CaffeineCacheManager.class)); customizers.customize(mock(CaffeineCacheManager.class));
assertThat(list.get(0).getCount()).isEqualTo(3); assertThat(list.get(0).getCount()).isEqualTo(3);
assertThat(list.get(1).getCount()).isEqualTo(1); assertThat(list.get(1).getCount()).isOne();
} }
static class CacheNamesCacheManagerCustomizer implements CacheManagerCustomizer<ConcurrentMapCacheManager> { static class CacheNamesCacheManagerCustomizer implements CacheManagerCustomizer<ConcurrentMapCacheManager> {

@ -122,7 +122,7 @@ class ConditionEvaluationReportTests {
this.report.recordConditionEvaluation("a", this.condition2, this.outcome2); this.report.recordConditionEvaluation("a", this.condition2, this.outcome2);
this.report.recordConditionEvaluation("b", this.condition3, this.outcome3); this.report.recordConditionEvaluation("b", this.condition3, this.outcome3);
Map<String, ConditionAndOutcomes> map = this.report.getConditionAndOutcomesBySource(); Map<String, ConditionAndOutcomes> map = this.report.getConditionAndOutcomesBySource();
assertThat(map.size()).isEqualTo(2); assertThat(map).hasSize(2);
Iterator<ConditionAndOutcome> iterator = map.get("a").iterator(); Iterator<ConditionAndOutcome> iterator = map.get("a").iterator();
ConditionAndOutcome conditionAndOutcome = iterator.next(); ConditionAndOutcome conditionAndOutcome = iterator.next();
assertThat(conditionAndOutcome.getCondition()).isEqualTo(this.condition1); assertThat(conditionAndOutcome.getCondition()).isEqualTo(this.condition1);
@ -164,7 +164,7 @@ class ConditionEvaluationReportTests {
void springBootConditionPopulatesReport() { void springBootConditionPopulatesReport() {
ConditionEvaluationReport report = ConditionEvaluationReport ConditionEvaluationReport report = ConditionEvaluationReport
.get(new AnnotationConfigApplicationContext(Config.class).getBeanFactory()); .get(new AnnotationConfigApplicationContext(Config.class).getBeanFactory());
assertThat(report.getConditionAndOutcomesBySource().size()).isNotEqualTo(0); assertThat(report.getConditionAndOutcomesBySource().size()).isNotZero();
} }
@Test @Test
@ -175,7 +175,6 @@ class ConditionEvaluationReportTests {
new ConditionOutcome(true, "Message 2")); new ConditionOutcome(true, "Message 2"));
ConditionAndOutcome outcome3 = new ConditionAndOutcome(this.condition3, ConditionAndOutcome outcome3 = new ConditionAndOutcome(this.condition3,
new ConditionOutcome(true, "Message 2")); new ConditionOutcome(true, "Message 2"));
assertThat(outcome1).isEqualTo(outcome1);
assertThat(outcome1).isNotEqualTo(outcome2); assertThat(outcome1).isNotEqualTo(outcome2);
assertThat(outcome2).isEqualTo(outcome3); assertThat(outcome2).isEqualTo(outcome3);
ConditionAndOutcomes outcomes = new ConditionAndOutcomes(); ConditionAndOutcomes outcomes = new ConditionAndOutcomes();

@ -48,49 +48,49 @@ class ConditionMessageTests {
@Test @Test
void toStringWhenEmptyShouldReturnEmptyString() { void toStringWhenEmptyShouldReturnEmptyString() {
ConditionMessage message = ConditionMessage.empty(); ConditionMessage message = ConditionMessage.empty();
assertThat(message.toString()).isEqualTo(""); assertThat(message).hasToString("");
} }
@Test @Test
void toStringWhenHasMessageShouldReturnMessage() { void toStringWhenHasMessageShouldReturnMessage() {
ConditionMessage message = ConditionMessage.of("Test"); ConditionMessage message = ConditionMessage.of("Test");
assertThat(message.toString()).isEqualTo("Test"); assertThat(message).hasToString("Test");
} }
@Test @Test
void appendWhenHasExistingMessageShouldAddSpace() { void appendWhenHasExistingMessageShouldAddSpace() {
ConditionMessage message = ConditionMessage.of("a").append("b"); ConditionMessage message = ConditionMessage.of("a").append("b");
assertThat(message.toString()).isEqualTo("a b"); assertThat(message).hasToString("a b");
} }
@Test @Test
void appendWhenAppendingNullShouldDoNothing() { void appendWhenAppendingNullShouldDoNothing() {
ConditionMessage message = ConditionMessage.of("a").append(null); ConditionMessage message = ConditionMessage.of("a").append(null);
assertThat(message.toString()).isEqualTo("a"); assertThat(message).hasToString("a");
} }
@Test @Test
void appendWhenNoMessageShouldNotAddSpace() { void appendWhenNoMessageShouldNotAddSpace() {
ConditionMessage message = ConditionMessage.empty().append("b"); ConditionMessage message = ConditionMessage.empty().append("b");
assertThat(message.toString()).isEqualTo("b"); assertThat(message).hasToString("b");
} }
@Test @Test
void andConditionWhenUsingClassShouldIncludeCondition() { void andConditionWhenUsingClassShouldIncludeCondition() {
ConditionMessage message = ConditionMessage.empty().andCondition(Test.class).because("OK"); ConditionMessage message = ConditionMessage.empty().andCondition(Test.class).because("OK");
assertThat(message.toString()).isEqualTo("@Test OK"); assertThat(message).hasToString("@Test OK");
} }
@Test @Test
void andConditionWhenUsingStringShouldIncludeCondition() { void andConditionWhenUsingStringShouldIncludeCondition() {
ConditionMessage message = ConditionMessage.empty().andCondition("@Test").because("OK"); ConditionMessage message = ConditionMessage.empty().andCondition("@Test").because("OK");
assertThat(message.toString()).isEqualTo("@Test OK"); assertThat(message).hasToString("@Test OK");
} }
@Test @Test
void andConditionWhenIncludingDetailsShouldIncludeCondition() { void andConditionWhenIncludingDetailsShouldIncludeCondition() {
ConditionMessage message = ConditionMessage.empty().andCondition(Test.class, "(a=b)").because("OK"); ConditionMessage message = ConditionMessage.empty().andCondition(Test.class, "(a=b)").because("OK");
assertThat(message.toString()).isEqualTo("@Test (a=b) OK"); assertThat(message).hasToString("@Test (a=b) OK");
} }
@Test @Test
@ -99,7 +99,7 @@ class ConditionMessageTests {
messages.add(ConditionMessage.of("a")); messages.add(ConditionMessage.of("a"));
messages.add(ConditionMessage.of("b")); messages.add(ConditionMessage.of("b"));
ConditionMessage message = ConditionMessage.of(messages); ConditionMessage message = ConditionMessage.of(messages);
assertThat(message.toString()).isEqualTo("a; b"); assertThat(message).hasToString("a; b");
} }
@Test @Test
@ -111,89 +111,89 @@ class ConditionMessageTests {
@Test @Test
void forConditionShouldIncludeCondition() { void forConditionShouldIncludeCondition() {
ConditionMessage message = ConditionMessage.forCondition("@Test").because("OK"); ConditionMessage message = ConditionMessage.forCondition("@Test").because("OK");
assertThat(message.toString()).isEqualTo("@Test OK"); assertThat(message).hasToString("@Test OK");
} }
@Test @Test
void forConditionShouldNotAddExtraSpaceWithEmptyCondition() { void forConditionShouldNotAddExtraSpaceWithEmptyCondition() {
ConditionMessage message = ConditionMessage.forCondition("").because("OK"); ConditionMessage message = ConditionMessage.forCondition("").because("OK");
assertThat(message.toString()).isEqualTo("OK"); assertThat(message).hasToString("OK");
} }
@Test @Test
void forConditionWhenClassShouldIncludeCondition() { void forConditionWhenClassShouldIncludeCondition() {
ConditionMessage message = ConditionMessage.forCondition(Test.class, "(a=b)").because("OK"); ConditionMessage message = ConditionMessage.forCondition(Test.class, "(a=b)").because("OK");
assertThat(message.toString()).isEqualTo("@Test (a=b) OK"); assertThat(message).hasToString("@Test (a=b) OK");
} }
@Test @Test
void foundExactlyShouldConstructMessage() { void foundExactlyShouldConstructMessage() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).foundExactly("abc"); ConditionMessage message = ConditionMessage.forCondition(Test.class).foundExactly("abc");
assertThat(message.toString()).isEqualTo("@Test found abc"); assertThat(message).hasToString("@Test found abc");
} }
@Test @Test
void foundWhenSingleElementShouldUseSingular() { void foundWhenSingleElementShouldUseSingular() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items("a"); ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items("a");
assertThat(message.toString()).isEqualTo("@Test found bean a"); assertThat(message).hasToString("@Test found bean a");
} }
@Test @Test
void foundNoneAtAllShouldConstructMessage() { void foundNoneAtAllShouldConstructMessage() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).found("no beans").atAll(); ConditionMessage message = ConditionMessage.forCondition(Test.class).found("no beans").atAll();
assertThat(message.toString()).isEqualTo("@Test found no beans"); assertThat(message).hasToString("@Test found no beans");
} }
@Test @Test
void foundWhenMultipleElementsShouldUsePlural() { void foundWhenMultipleElementsShouldUsePlural() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items("a", "b", ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items("a", "b",
"c"); "c");
assertThat(message.toString()).isEqualTo("@Test found beans a, b, c"); assertThat(message).hasToString("@Test found beans a, b, c");
} }
@Test @Test
void foundWhenQuoteStyleShouldQuote() { void foundWhenQuoteStyleShouldQuote() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items(Style.QUOTE, ConditionMessage message = ConditionMessage.forCondition(Test.class).found("bean", "beans").items(Style.QUOTE,
"a", "b", "c"); "a", "b", "c");
assertThat(message.toString()).isEqualTo("@Test found beans 'a', 'b', 'c'"); assertThat(message).hasToString("@Test found beans 'a', 'b', 'c'");
} }
@Test @Test
void didNotFindWhenSingleElementShouldUseSingular() { void didNotFindWhenSingleElementShouldUseSingular() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("class", "classes").items("a"); ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("class", "classes").items("a");
assertThat(message.toString()).isEqualTo("@Test did not find class a"); assertThat(message).hasToString("@Test did not find class a");
} }
@Test @Test
void didNotFindWhenMultipleElementsShouldUsePlural() { void didNotFindWhenMultipleElementsShouldUsePlural() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("class", "classes").items("a", ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("class", "classes").items("a",
"b", "c"); "b", "c");
assertThat(message.toString()).isEqualTo("@Test did not find classes a, b, c"); assertThat(message).hasToString("@Test did not find classes a, b, c");
} }
@Test @Test
void resultedInShouldConstructMessage() { void resultedInShouldConstructMessage() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).resultedIn("Green"); ConditionMessage message = ConditionMessage.forCondition(Test.class).resultedIn("Green");
assertThat(message.toString()).isEqualTo("@Test resulted in Green"); assertThat(message).hasToString("@Test resulted in Green");
} }
@Test @Test
void notAvailableShouldConstructMessage() { void notAvailableShouldConstructMessage() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).notAvailable("JMX"); ConditionMessage message = ConditionMessage.forCondition(Test.class).notAvailable("JMX");
assertThat(message.toString()).isEqualTo("@Test JMX is not available"); assertThat(message).hasToString("@Test JMX is not available");
} }
@Test @Test
void availableShouldConstructMessage() { void availableShouldConstructMessage() {
ConditionMessage message = ConditionMessage.forCondition(Test.class).available("JMX"); ConditionMessage message = ConditionMessage.forCondition(Test.class).available("JMX");
assertThat(message.toString()).isEqualTo("@Test JMX is available"); assertThat(message).hasToString("@Test JMX is available");
} }
@Test @Test
void itemsTolerateNullInput() { void itemsTolerateNullInput() {
Collection<?> items = null; Collection<?> items = null;
ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("item").items(items); ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("item").items(items);
assertThat(message.toString()).isEqualTo("@Test did not find item"); assertThat(message).hasToString("@Test did not find item");
} }
@Test @Test
@ -201,7 +201,7 @@ class ConditionMessageTests {
Collection<?> items = null; Collection<?> items = null;
ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("item").items(Style.QUOTE, ConditionMessage message = ConditionMessage.forCondition(Test.class).didNotFind("item").items(Style.QUOTE,
items); items);
assertThat(message.toString()).isEqualTo("@Test did not find item"); assertThat(message).hasToString("@Test did not find item");
} }
} }

@ -58,7 +58,7 @@ class ConditionalOnSingleCandidateTests {
.withUserConfiguration(AlphaScopedProxyConfiguration.class, OnBeanSingleCandidateConfiguration.class) .withUserConfiguration(AlphaScopedProxyConfiguration.class, OnBeanSingleCandidateConfiguration.class)
.run((context) -> { .run((context) -> {
assertThat(context).hasBean("consumer"); assertThat(context).hasBean("consumer");
assertThat(context.getBean("consumer").toString()).isEqualTo("alpha"); assertThat(context.getBean("consumer")).hasToString("alpha");
}); });
} }

@ -35,7 +35,7 @@ class CouchbasePropertiesTests {
@Test @Test
void ioHaveConsistentDefaults() { void ioHaveConsistentDefaults() {
Io io = new CouchbaseProperties().getEnv().getIo(); Io io = new CouchbaseProperties().getEnv().getIo();
assertThat(io.getMinEndpoints()).isEqualTo(IoConfig.DEFAULT_NUM_KV_CONNECTIONS); assertThat(io.getMinEndpoints()).isOne();
assertThat(io.getMaxEndpoints()).isEqualTo(IoConfig.DEFAULT_MAX_HTTP_CONNECTIONS); assertThat(io.getMaxEndpoints()).isEqualTo(IoConfig.DEFAULT_MAX_HTTP_CONNECTIONS);
assertThat(io.getIdleHttpConnectionTimeout()).isEqualTo(IoConfig.DEFAULT_IDLE_HTTP_CONNECTION_TIMEOUT); assertThat(io.getIdleHttpConnectionTimeout()).isEqualTo(IoConfig.DEFAULT_IDLE_HTTP_CONNECTION_TIMEOUT);
} }

@ -61,7 +61,7 @@ class Neo4jRepositoriesAutoConfigurationIntegrationTests {
@Test @Test
void ensureRepositoryIsReady() { void ensureRepositoryIsReady() {
assertThat(this.countryRepository.count()).isEqualTo(0); assertThat(this.countryRepository.count()).isZero();
} }
@Configuration @Configuration

@ -64,7 +64,7 @@ class RedisAutoConfigurationJedisTests {
.run((context) -> { .run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class); JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1); assertThat(cf.getDatabase()).isOne();
assertThat(getUserName(cf)).isNull(); assertThat(getUserName(cf)).isNull();
assertThat(cf.getPassword()).isNull(); assertThat(cf.getPassword()).isNull();
assertThat(cf.isUseSsl()).isFalse(); assertThat(cf.isUseSsl()).isFalse();
@ -112,7 +112,7 @@ class RedisAutoConfigurationJedisTests {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class); JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example"); assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33); assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo(""); assertThat(getUserName(cf)).isEmpty();
assertThat(cf.getPassword()).isEqualTo("pass:word"); assertThat(cf.getPassword()).isEqualTo("pass:word");
}); });
} }
@ -137,7 +137,7 @@ class RedisAutoConfigurationJedisTests {
"spring.data.redis.jedis.pool.time-between-eviction-runs:30000").run((context) -> { "spring.data.redis.jedis.pool.time-between-eviction-runs:30000").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class); JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getPoolConfig().getMinIdle()).isEqualTo(1); assertThat(cf.getPoolConfig().getMinIdle()).isOne();
assertThat(cf.getPoolConfig().getMaxIdle()).isEqualTo(4); assertThat(cf.getPoolConfig().getMaxIdle()).isEqualTo(4);
assertThat(cf.getPoolConfig().getMaxTotal()).isEqualTo(16); assertThat(cf.getPoolConfig().getMaxTotal()).isEqualTo(16);
assertThat(cf.getPoolConfig().getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2)); assertThat(cf.getPoolConfig().getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2));
@ -152,7 +152,7 @@ class RedisAutoConfigurationJedisTests {
.run((context) -> { .run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class); JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getClientConfiguration().isUsePooling()).isEqualTo(false); assertThat(cf.getClientConfiguration().isUsePooling()).isFalse();
}); });
} }

@ -26,7 +26,6 @@ import java.util.stream.Collectors;
import io.lettuce.core.ClientOptions; import io.lettuce.core.ClientOptions;
import io.lettuce.core.cluster.ClusterClientOptions; import io.lettuce.core.cluster.ClusterClientOptions;
import io.lettuce.core.cluster.ClusterTopologyRefreshOptions;
import io.lettuce.core.cluster.ClusterTopologyRefreshOptions.RefreshTrigger; import io.lettuce.core.cluster.ClusterTopologyRefreshOptions.RefreshTrigger;
import io.lettuce.core.resource.DefaultClientResources; import io.lettuce.core.resource.DefaultClientResources;
import io.lettuce.core.tracing.Tracing; import io.lettuce.core.tracing.Tracing;
@ -94,7 +93,7 @@ class RedisAutoConfigurationTests {
"spring.data.redis.lettuce.shutdown-timeout:500").run((context) -> { "spring.data.redis.lettuce.shutdown-timeout:500").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class); LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1); assertThat(cf.getDatabase()).isOne();
assertThat(getUserName(cf)).isNull(); assertThat(getUserName(cf)).isNull();
assertThat(cf.getPassword()).isNull(); assertThat(cf.getPassword()).isNull();
assertThat(cf.isUseSsl()).isFalse(); assertThat(cf.isUseSsl()).isFalse();
@ -153,7 +152,7 @@ class RedisAutoConfigurationTests {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class); LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example"); assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33); assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo(""); assertThat(getUserName(cf)).isEmpty();
assertThat(cf.getPassword()).isEqualTo("pass:word"); assertThat(cf.getPassword()).isEqualTo("pass:word");
}); });
} }
@ -194,7 +193,7 @@ class RedisAutoConfigurationTests {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class); LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getHostName()).isEqualTo("foo");
GenericObjectPoolConfig<?> poolConfig = getPoolingClientConfiguration(cf).getPoolConfig(); GenericObjectPoolConfig<?> poolConfig = getPoolingClientConfiguration(cf).getPoolConfig();
assertThat(poolConfig.getMinIdle()).isEqualTo(1); assertThat(poolConfig.getMinIdle()).isOne();
assertThat(poolConfig.getMaxIdle()).isEqualTo(4); assertThat(poolConfig.getMaxIdle()).isEqualTo(4);
assertThat(poolConfig.getMaxTotal()).isEqualTo(16); assertThat(poolConfig.getMaxTotal()).isEqualTo(16);
assertThat(poolConfig.getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2)); assertThat(poolConfig.getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2));
@ -298,7 +297,7 @@ class RedisAutoConfigurationTests {
"spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380") "spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.run((context) -> { .run((context) -> {
LettuceConnectionFactory connectionFactory = context.getBean(LettuceConnectionFactory.class); LettuceConnectionFactory connectionFactory = context.getBean(LettuceConnectionFactory.class);
assertThat(connectionFactory.getDatabase()).isEqualTo(1); assertThat(connectionFactory.getDatabase()).isOne();
assertThat(connectionFactory.isRedisSentinelAware()).isTrue(); assertThat(connectionFactory.isRedisSentinelAware()).isTrue();
}); });
} }
@ -467,7 +466,7 @@ class RedisAutoConfigurationTests {
"spring.data.redis.lettuce.cluster.refresh.dynamic-sources=") "spring.data.redis.lettuce.cluster.refresh.dynamic-sources=")
.run(assertClientOptions(ClusterClientOptions.class, .run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().useDynamicRefreshSources()) (options) -> assertThat(options.getTopologyRefreshOptions().useDynamicRefreshSources())
.isEqualTo(ClusterTopologyRefreshOptions.DEFAULT_DYNAMIC_REFRESH_SOURCES))); .isTrue()));
} }
private <T extends ClientOptions> ContextConsumer<AssertableApplicationContext> assertClientOptions( private <T extends ClientOptions> ContextConsumer<AssertableApplicationContext> assertClientOptions(

@ -272,7 +272,7 @@ class FlywayAutoConfigurationTests {
.withPropertyValues("spring.flyway.schemas:public").run((context) -> { .withPropertyValues("spring.flyway.schemas:public").run((context) -> {
assertThat(context).hasSingleBean(Flyway.class); assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class); Flyway flyway = context.getBean(Flyway.class);
assertThat(Arrays.asList(flyway.getConfiguration().getSchemas()).toString()).isEqualTo("[public]"); assertThat(Arrays.asList(flyway.getConfiguration().getSchemas())).hasToString("[public]");
}); });
} }

@ -119,7 +119,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
@Test @Test
void disableCache() { void disableCache() {
load("spring.freemarker.cache:false"); load("spring.freemarker.cache:false");
assertThat(this.context.getBean(FreeMarkerViewResolver.class).getCacheLimit()).isEqualTo(0); assertThat(this.context.getBean(FreeMarkerViewResolver.class).getCacheLimit()).isZero();
} }
@Test @Test

@ -152,7 +152,7 @@ class GroovyTemplateAutoConfigurationTests {
@Test @Test
void disableCache() { void disableCache() {
registerAndRefreshContext("spring.groovy.template.cache:false"); registerAndRefreshContext("spring.groovy.template.cache:false");
assertThat(this.context.getBean(GroovyMarkupViewResolver.class).getCacheLimit()).isEqualTo(0); assertThat(this.context.getBean(GroovyMarkupViewResolver.class).getCacheLimit()).isZero();
} }
@Test @Test

@ -93,7 +93,7 @@ class HypermediaAutoConfigurationTests {
RequestMappingHandlerAdapter handlerAdapter = context.getBean(RequestMappingHandlerAdapter.class); RequestMappingHandlerAdapter handlerAdapter = context.getBean(RequestMappingHandlerAdapter.class);
Optional<HttpMessageConverter<?>> mappingJacksonConverter = handlerAdapter.getMessageConverters().stream() Optional<HttpMessageConverter<?>> mappingJacksonConverter = handlerAdapter.getMessageConverters().stream()
.filter(MappingJackson2HttpMessageConverter.class::isInstance).findFirst(); .filter(MappingJackson2HttpMessageConverter.class::isInstance).findFirst();
assertThat(mappingJacksonConverter).isPresent().hasValueSatisfying( assertThat(mappingJacksonConverter).hasValueSatisfying(
(converter) -> assertThat(converter.canWrite(RepresentationModel.class, MediaType.APPLICATION_JSON)) (converter) -> assertThat(converter.canWrite(RepresentationModel.class, MediaType.APPLICATION_JSON))
.isTrue()); .isTrue());
}); });
@ -106,10 +106,8 @@ class HypermediaAutoConfigurationTests {
RequestMappingHandlerAdapter handlerAdapter = context.getBean(RequestMappingHandlerAdapter.class); RequestMappingHandlerAdapter handlerAdapter = context.getBean(RequestMappingHandlerAdapter.class);
Optional<HttpMessageConverter<?>> mappingJacksonConverter = handlerAdapter.getMessageConverters() Optional<HttpMessageConverter<?>> mappingJacksonConverter = handlerAdapter.getMessageConverters()
.stream().filter(MappingJackson2HttpMessageConverter.class::isInstance).findFirst(); .stream().filter(MappingJackson2HttpMessageConverter.class::isInstance).findFirst();
assertThat(mappingJacksonConverter).isPresent() assertThat(mappingJacksonConverter).hasValueSatisfying((converter) -> assertThat(
.hasValueSatisfying((converter) -> assertThat( converter.canWrite(RepresentationModel.class, MediaType.APPLICATION_JSON)).isFalse());
converter.canWrite(RepresentationModel.class, MediaType.APPLICATION_JSON))
.isFalse());
}); });
} }

@ -64,8 +64,8 @@ class HttpMessageConvertersTests {
MappingJackson2HttpMessageConverter converter1 = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter1 = new MappingJackson2HttpMessageConverter();
MappingJackson2HttpMessageConverter converter2 = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter2 = new MappingJackson2HttpMessageConverter();
HttpMessageConverters converters = new HttpMessageConverters(converter1, converter2); HttpMessageConverters converters = new HttpMessageConverters(converter1, converter2);
assertThat(converters.getConverters().contains(converter1)).isTrue(); assertThat(converters.getConverters()).contains(converter1);
assertThat(converters.getConverters().contains(converter2)).isTrue(); assertThat(converters.getConverters()).contains(converter2);
List<MappingJackson2HttpMessageConverter> httpConverters = new ArrayList<>(); List<MappingJackson2HttpMessageConverter> httpConverters = new ArrayList<>();
for (HttpMessageConverter<?> candidate : converters) { for (HttpMessageConverter<?> candidate : converters) {
if (candidate instanceof MappingJackson2HttpMessageConverter) { if (candidate instanceof MappingJackson2HttpMessageConverter) {
@ -74,9 +74,9 @@ class HttpMessageConvertersTests {
} }
// The existing converter is still there, but with a lower priority // The existing converter is still there, but with a lower priority
assertThat(httpConverters).hasSize(3); assertThat(httpConverters).hasSize(3);
assertThat(httpConverters.indexOf(converter1)).isEqualTo(0); assertThat(httpConverters.indexOf(converter1)).isZero();
assertThat(httpConverters.indexOf(converter2)).isEqualTo(1); assertThat(httpConverters.indexOf(converter2)).isOne();
assertThat(converters.getConverters().indexOf(converter1)).isNotEqualTo(0); assertThat(converters.getConverters().indexOf(converter1)).isNotZero();
} }
@Test @Test

@ -74,7 +74,7 @@ class CodecsAutoConfigurationTests {
CodecsAutoConfiguration.DefaultCodecsConfiguration.class, "defaultCodecCustomizer", CodecsAutoConfiguration.DefaultCodecsConfiguration.class, "defaultCodecCustomizer",
CodecProperties.class); CodecProperties.class);
Integer order = new TestAnnotationAwareOrderComparator().findOrder(customizerMethod); Integer order = new TestAnnotationAwareOrderComparator().findOrder(customizerMethod);
assertThat(order).isEqualTo(0); assertThat(order).isZero();
}); });
} }

@ -423,7 +423,7 @@ class IntegrationAutoConfigurationTests {
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(PollerMetadata.class); assertThat(context).hasSingleBean(PollerMetadata.class);
PollerMetadata metadata = context.getBean(PollerMetadata.DEFAULT_POLLER, PollerMetadata.class); PollerMetadata metadata = context.getBean(PollerMetadata.DEFAULT_POLLER, PollerMetadata.class);
assertThat(metadata.getMaxMessagesPerPoll()).isEqualTo(1L); assertThat(metadata.getMaxMessagesPerPoll()).isOne();
assertThat(metadata.getReceiveTimeout()).isEqualTo(10000L); assertThat(metadata.getReceiveTimeout()).isEqualTo(10000L);
assertThat(metadata.getTrigger()).asInstanceOf(InstanceOfAssertFactories.type(CronTrigger.class)) assertThat(metadata.getTrigger()).asInstanceOf(InstanceOfAssertFactories.type(CronTrigger.class))
.satisfies((trigger) -> assertThat(trigger.getExpression()).isEqualTo("* * * ? * *")); .satisfies((trigger) -> assertThat(trigger.getExpression()).isEqualTo("* * * ? * *"));

@ -102,7 +102,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
new IntegrationPropertiesEnvironmentPostProcessor().registerIntegrationPropertiesPropertySource(environment, new IntegrationPropertiesEnvironmentPostProcessor().registerIntegrationPropertiesPropertySource(environment,
resource); resource);
PropertySource<?> ps = environment.getPropertySources().get("META-INF/spring.integration.properties"); PropertySource<?> ps = environment.getPropertySources().get("META-INF/spring.integration.properties");
assertThat(ps).isNotNull().isInstanceOf(OriginLookup.class); assertThat(ps).isInstanceOf(OriginLookup.class);
OriginLookup<String> originLookup = (OriginLookup<String>) ps; OriginLookup<String> originLookup = (OriginLookup<String>) ps;
assertThat(originLookup.getOrigin("spring.integration.channel.auto-create")) assertThat(originLookup.getOrigin("spring.integration.channel.auto-create"))
.satisfies(textOrigin(resource, 0, 39)); .satisfies(textOrigin(resource, 0, 39));

@ -88,8 +88,8 @@ class DataSourceJmxConfigurationTests {
hikariDataSource.getConnection().close(); hikariDataSource.getConnection().close();
// We can't rely on the number of MBeans so we're checking that the // We can't rely on the number of MBeans so we're checking that the
// pool and pool config MBeans were registered // pool and pool config MBeans were registered
assertThat(mBeanServer.queryMBeans(new ObjectName("com.zaxxer.hikari:type=*"), null).size()) assertThat(mBeanServer.queryMBeans(new ObjectName("com.zaxxer.hikari:type=*"), null))
.isEqualTo(existingInstances.size() + 2); .hasSize(existingInstances.size() + 2);
}); });
} }

@ -60,7 +60,7 @@ class DataSourceJsonSerializationTests {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.setSerializerFactory(factory); mapper.setSerializerFactory(factory);
String value = mapper.writeValueAsString(dataSource); String value = mapper.writeValueAsString(dataSource);
assertThat(value.contains("\"url\":")).isTrue(); assertThat(value).contains("\"url\":");
} }
@Test @Test
@ -69,8 +69,8 @@ class DataSourceJsonSerializationTests {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(DataSource.class, DataSourceJson.class); mapper.addMixIn(DataSource.class, DataSourceJson.class);
String value = mapper.writeValueAsString(dataSource); String value = mapper.writeValueAsString(dataSource);
assertThat(value.contains("\"url\":")).isTrue(); assertThat(value).contains("\"url\":");
assertThat(StringUtils.countOccurrencesOf(value, "\"url\"")).isEqualTo(1); assertThat(StringUtils.countOccurrencesOf(value, "\"url\"")).isOne();
} }
@JsonSerialize(using = TomcatDataSourceSerializer.class) @JsonSerialize(using = TomcatDataSourceSerializer.class)

@ -121,7 +121,7 @@ class DataSourcePropertiesTests {
DataSourceProperties properties = new DataSourceProperties(); DataSourceProperties properties = new DataSourceProperties();
properties.setUsername(""); properties.setUsername("");
properties.afterPropertiesSet(); properties.afterPropertiesSet();
assertThat(properties.getUsername()).isEqualTo(""); assertThat(properties.getUsername()).isEmpty();
assertThat(properties.determineUsername()).isEqualTo("sa"); assertThat(properties.determineUsername()).isEqualTo("sa");
} }
@ -157,7 +157,7 @@ class DataSourcePropertiesTests {
DataSourceProperties properties = new DataSourceProperties(); DataSourceProperties properties = new DataSourceProperties();
properties.afterPropertiesSet(); properties.afterPropertiesSet();
assertThat(properties.getPassword()).isNull(); assertThat(properties.getPassword()).isNull();
assertThat(properties.determinePassword()).isEqualTo(""); assertThat(properties.determinePassword()).isEmpty();
} }
@Test @Test

@ -150,7 +150,7 @@ class JdbcTemplateAutoConfigurationTests {
this.contextRunner.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class)) this.contextRunner.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class))
.withUserConfiguration(DataSourceInitializationValidator.class).run((context) -> { .withUserConfiguration(DataSourceInitializationValidator.class).run((context) -> {
assertThat(context).hasNotFailed(); assertThat(context).hasNotFailed();
assertThat(context.getBean(DataSourceInitializationValidator.class).count).isEqualTo(1); assertThat(context.getBean(DataSourceInitializationValidator.class).count).isOne();
}); });
} }
@ -160,7 +160,7 @@ class JdbcTemplateAutoConfigurationTests {
.withPropertyValues("spring.flyway.locations:classpath:db/city") .withPropertyValues("spring.flyway.locations:classpath:db/city")
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).run((context) -> {
assertThat(context).hasNotFailed(); assertThat(context).hasNotFailed();
assertThat(context.getBean(DataSourceMigrationValidator.class).count).isEqualTo(0); assertThat(context.getBean(DataSourceMigrationValidator.class).count).isZero();
}); });
} }
@ -171,7 +171,7 @@ class JdbcTemplateAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).run((context) -> {
assertThat(context).hasNotFailed(); assertThat(context).hasNotFailed();
assertThat(context.getBean(JdbcTemplate.class)).isNotNull(); assertThat(context.getBean(JdbcTemplate.class)).isNotNull();
assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isEqualTo(0); assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isZero();
}); });
} }
@ -181,7 +181,7 @@ class JdbcTemplateAutoConfigurationTests {
.withPropertyValues("spring.liquibase.changeLog:classpath:db/changelog/db.changelog-city.yaml") .withPropertyValues("spring.liquibase.changeLog:classpath:db/changelog/db.changelog-city.yaml")
.withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class)).run((context) -> {
assertThat(context).hasNotFailed(); assertThat(context).hasNotFailed();
assertThat(context.getBean(DataSourceMigrationValidator.class).count).isEqualTo(0); assertThat(context.getBean(DataSourceMigrationValidator.class).count).isZero();
}); });
} }
@ -192,7 +192,7 @@ class JdbcTemplateAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class)).run((context) -> { .withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class)).run((context) -> {
assertThat(context).hasNotFailed(); assertThat(context).hasNotFailed();
assertThat(context.getBean(JdbcTemplate.class)).isNotNull(); assertThat(context.getBean(JdbcTemplate.class)).isNotNull();
assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isEqualTo(0); assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isZero();
}); });
} }

@ -75,13 +75,13 @@ class OracleUcpDataSourceConfigurationTests {
void testDataSourceDefaultsPreserved() { void testDataSourceDefaultsPreserved() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
PoolDataSourceImpl ds = context.getBean(PoolDataSourceImpl.class); PoolDataSourceImpl ds = context.getBean(PoolDataSourceImpl.class);
assertThat(ds.getInitialPoolSize()).isEqualTo(0); assertThat(ds.getInitialPoolSize()).isZero();
assertThat(ds.getMinPoolSize()).isEqualTo(0); assertThat(ds.getMinPoolSize()).isZero();
assertThat(ds.getMaxPoolSize()).isEqualTo(Integer.MAX_VALUE); assertThat(ds.getMaxPoolSize()).isEqualTo(Integer.MAX_VALUE);
assertThat(ds.getInactiveConnectionTimeout()).isEqualTo(0); assertThat(ds.getInactiveConnectionTimeout()).isZero();
assertThat(ds.getConnectionWaitTimeout()).isEqualTo(3); assertThat(ds.getConnectionWaitTimeout()).isEqualTo(3);
assertThat(ds.getTimeToLiveConnectionTimeout()).isEqualTo(0); assertThat(ds.getTimeToLiveConnectionTimeout()).isZero();
assertThat(ds.getAbandonedConnectionTimeout()).isEqualTo(0); assertThat(ds.getAbandonedConnectionTimeout()).isZero();
assertThat(ds.getTimeoutCheckInterval()).isEqualTo(30); assertThat(ds.getTimeoutCheckInterval()).isEqualTo(30);
assertThat(ds.getFastConnectionFailoverEnabled()).isFalse(); assertThat(ds.getFastConnectionFailoverEnabled()).isFalse();
}); });

@ -61,7 +61,7 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
void contextLoads() { void contextLoads() {
ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class); ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode()); assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
assertThat("{\"subject\":\"Jersey\"}").isEqualTo(response.getBody()); assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}");
} }
@MinimalWebConfiguration @MinimalWebConfiguration

@ -261,7 +261,7 @@ class JmsAutoConfigurationTests {
assertThat(jmsTemplate.isPubSubDomain()).isFalse(); assertThat(jmsTemplate.isPubSubDomain()).isFalse();
assertThat(jmsTemplate.getDefaultDestinationName()).isEqualTo("testQueue"); assertThat(jmsTemplate.getDefaultDestinationName()).isEqualTo("testQueue");
assertThat(jmsTemplate.getDeliveryDelay()).isEqualTo(500); assertThat(jmsTemplate.getDeliveryDelay()).isEqualTo(500);
assertThat(jmsTemplate.getDeliveryMode()).isEqualTo(1); assertThat(jmsTemplate.getDeliveryMode()).isOne();
assertThat(jmsTemplate.getPriority()).isEqualTo(6); assertThat(jmsTemplate.getPriority()).isEqualTo(6);
assertThat(jmsTemplate.getTimeToLive()).isEqualTo(6000); assertThat(jmsTemplate.getTimeToLive()).isEqualTo(6000);
assertThat(jmsTemplate.isExplicitQosEnabled()).isTrue(); assertThat(jmsTemplate.isExplicitQosEnabled()).isTrue();

@ -77,7 +77,7 @@ class ArtemisAutoConfigurationTests {
assertThat(connectionFactory.getTargetConnectionFactory()).isInstanceOf(ActiveMQConnectionFactory.class); assertThat(connectionFactory.getTargetConnectionFactory()).isInstanceOf(ActiveMQConnectionFactory.class);
assertThat(connectionFactory.isCacheConsumers()).isFalse(); assertThat(connectionFactory.isCacheConsumers()).isFalse();
assertThat(connectionFactory.isCacheProducers()).isTrue(); assertThat(connectionFactory.isCacheProducers()).isTrue();
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1); assertThat(connectionFactory.getSessionCacheSize()).isOne();
}); });
} }
@ -374,7 +374,7 @@ class ArtemisAutoConfigurationTests {
String host, int port) { String host, int port) {
TransportConfiguration transportConfig = getSingleTransportConfiguration(connectionFactory); TransportConfiguration transportConfig = getSingleTransportConfiguration(connectionFactory);
assertThat(transportConfig.getFactoryClassName()).isEqualTo(NettyConnectorFactory.class.getName()); assertThat(transportConfig.getFactoryClassName()).isEqualTo(NettyConnectorFactory.class.getName());
assertThat(transportConfig.getParams().get("host")).isEqualTo(host); assertThat(transportConfig.getParams()).containsEntry("host", host);
Object transportConfigPort = transportConfig.getParams().get("port"); Object transportConfigPort = transportConfig.getParams().get("port");
if (transportConfigPort instanceof String portString) { if (transportConfigPort instanceof String portString) {
transportConfigPort = Integer.parseInt(portString); transportConfigPort = Integer.parseInt(portString);

@ -171,7 +171,7 @@ class JooqAutoConfigurationTests {
@Override @Override
public void run(org.jooq.Configuration configuration) { public void run(org.jooq.Configuration configuration) {
assertThat(this.dsl.fetch(this.sql).getValue(0, 0).toString()).isEqualTo(this.expected); assertThat(this.dsl.fetch(this.sql).getValue(0, 0)).hasToString(this.expected);
} }
} }

@ -91,7 +91,7 @@ class KafkaAutoConfigurationIntegrationTests {
DefaultKafkaProducerFactory producerFactory = this.context.getBean(DefaultKafkaProducerFactory.class); DefaultKafkaProducerFactory producerFactory = this.context.getBean(DefaultKafkaProducerFactory.class);
Producer producer = producerFactory.createProducer(); Producer producer = producerFactory.createProducer();
assertThat(producer.partitionsFor(ADMIN_CREATED_TOPIC).size()).isEqualTo(10); assertThat(producer.partitionsFor(ADMIN_CREATED_TOPIC)).hasSize(10);
producer.close(); producer.close();
} }

@ -121,38 +121,38 @@ class KafkaAutoConfigurationTests {
.getBean(DefaultKafkaConsumerFactory.class); .getBean(DefaultKafkaConsumerFactory.class);
Map<String, Object> configs = consumerFactory.getConfigurationProperties(); Map<String, Object> configs = consumerFactory.getConfigurationProperties();
// common // common
assertThat(configs.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)) assertThat(configs).containsEntry(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,
.isEqualTo(Collections.singletonList("foo:1234")); Collections.singletonList("foo:1234"));
assertThat(configs.get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)).isEqualTo("p1"); assertThat(configs).containsEntry(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "p1");
assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "ksLoc"); .endsWith(File.separator + "ksLoc");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)).isEqualTo("p2"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "p2");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, "PKCS12");
assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "tsLoc"); .endsWith(File.separator + "tsLoc");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).isEqualTo("p3"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "p3");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "PKCS12");
assertThat(configs.get(SslConfigs.SSL_PROTOCOL_CONFIG)).isEqualTo("TLSv1.2"); assertThat(configs).containsEntry(SslConfigs.SSL_PROTOCOL_CONFIG, "TLSv1.2");
// consumer // consumer
assertThat(configs.get(ConsumerConfig.CLIENT_ID_CONFIG)).isEqualTo("ccid"); // override assertThat(configs).containsEntry(ConsumerConfig.CLIENT_ID_CONFIG, "ccid"); // override
assertThat(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)).isEqualTo(Boolean.FALSE); assertThat(configs).containsEntry(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, Boolean.FALSE);
assertThat(configs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG)).isEqualTo(123); assertThat(configs).containsEntry(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, 123);
assertThat(configs.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG)).isEqualTo("earliest"); assertThat(configs).containsEntry(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
assertThat(configs.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG)).isEqualTo(456); assertThat(configs).containsEntry(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG, 456);
assertThat(configs.get(ConsumerConfig.FETCH_MIN_BYTES_CONFIG)).isEqualTo(1024); assertThat(configs).containsEntry(ConsumerConfig.FETCH_MIN_BYTES_CONFIG, 1024);
assertThat(configs.get(ConsumerConfig.GROUP_ID_CONFIG)).isEqualTo("bar"); assertThat(configs).containsEntry(ConsumerConfig.GROUP_ID_CONFIG, "bar");
assertThat(configs.get(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG)).isEqualTo(234); assertThat(configs).containsEntry(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, 234);
assertThat(configs.get(ConsumerConfig.ISOLATION_LEVEL_CONFIG)).isEqualTo("read_committed"); assertThat(configs).containsEntry(ConsumerConfig.ISOLATION_LEVEL_CONFIG, "read_committed");
assertThat(configs.get(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG)) assertThat(configs).containsEntry(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
.isEqualTo(LongDeserializer.class); LongDeserializer.class);
assertThat(configs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL"); assertThat(configs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
assertThat(configs.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG)) assertThat(configs).containsEntry(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
.isEqualTo(IntegerDeserializer.class); IntegerDeserializer.class);
assertThat(configs.get(ConsumerConfig.MAX_POLL_RECORDS_CONFIG)).isEqualTo(42); assertThat(configs).containsEntry(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 42);
assertThat(configs.get("foo")).isEqualTo("bar"); assertThat(configs).containsEntry("foo", "bar");
assertThat(configs.get("baz")).isEqualTo("qux"); assertThat(configs).containsEntry("baz", "qux");
assertThat(configs.get("foo.bar.baz")).isEqualTo("qux.fiz.buz"); assertThat(configs).containsEntry("foo.bar.baz", "qux.fiz.buz");
assertThat(configs.get("fiz.buz")).isEqualTo("fix.fox"); assertThat(configs).containsEntry("fiz.buz", "fix.fox");
}); });
} }
@ -177,33 +177,33 @@ class KafkaAutoConfigurationTests {
.getBean(DefaultKafkaProducerFactory.class); .getBean(DefaultKafkaProducerFactory.class);
Map<String, Object> configs = producerFactory.getConfigurationProperties(); Map<String, Object> configs = producerFactory.getConfigurationProperties();
// common // common
assertThat(configs.get(ProducerConfig.CLIENT_ID_CONFIG)).isEqualTo("cid"); assertThat(configs).containsEntry(ProducerConfig.CLIENT_ID_CONFIG, "cid");
// producer // producer
assertThat(configs.get(ProducerConfig.ACKS_CONFIG)).isEqualTo("all"); assertThat(configs).containsEntry(ProducerConfig.ACKS_CONFIG, "all");
assertThat(configs.get(ProducerConfig.BATCH_SIZE_CONFIG)).isEqualTo(2048); assertThat(configs).containsEntry(ProducerConfig.BATCH_SIZE_CONFIG, 2048);
assertThat(configs.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)) assertThat(configs).containsEntry(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
.isEqualTo(Collections.singletonList("bar:1234")); // override Collections.singletonList("bar:1234")); // override
assertThat(configs.get(ProducerConfig.BUFFER_MEMORY_CONFIG)).isEqualTo(4096L); assertThat(configs).containsEntry(ProducerConfig.BUFFER_MEMORY_CONFIG, 4096L);
assertThat(configs.get(ProducerConfig.COMPRESSION_TYPE_CONFIG)).isEqualTo("gzip"); assertThat(configs).containsEntry(ProducerConfig.COMPRESSION_TYPE_CONFIG, "gzip");
assertThat(configs.get(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG)).isEqualTo(LongSerializer.class); assertThat(configs).containsEntry(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class);
assertThat(configs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL"); assertThat(configs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
assertThat(configs.get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)).isEqualTo("p4"); assertThat(configs).containsEntry(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "p4");
assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "ksLocP"); .endsWith(File.separator + "ksLocP");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)).isEqualTo("p5"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "p5");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, "PKCS12");
assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "tsLocP"); .endsWith(File.separator + "tsLocP");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).isEqualTo("p6"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "p6");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "PKCS12");
assertThat(configs.get(SslConfigs.SSL_PROTOCOL_CONFIG)).isEqualTo("TLSv1.2"); assertThat(configs).containsEntry(SslConfigs.SSL_PROTOCOL_CONFIG, "TLSv1.2");
assertThat(configs.get(ProducerConfig.RETRIES_CONFIG)).isEqualTo(2); assertThat(configs).containsEntry(ProducerConfig.RETRIES_CONFIG, 2);
assertThat(configs.get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG)) assertThat(configs).containsEntry(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
.isEqualTo(IntegerSerializer.class); IntegerSerializer.class);
assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty(); assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty();
assertThat(context.getBeansOfType(KafkaTransactionManager.class)).isEmpty(); assertThat(context.getBeansOfType(KafkaTransactionManager.class)).isEmpty();
assertThat(configs.get("foo.bar.baz")).isEqualTo("qux.fiz.buz"); assertThat(configs).containsEntry("foo.bar.baz", "qux.fiz.buz");
assertThat(configs.get("fiz.buz")).isEqualTo("fix.fox"); assertThat(configs).containsEntry("fiz.buz", "fix.fox");
}); });
} }
@ -221,22 +221,22 @@ class KafkaAutoConfigurationTests {
KafkaAdmin admin = context.getBean(KafkaAdmin.class); KafkaAdmin admin = context.getBean(KafkaAdmin.class);
Map<String, Object> configs = admin.getConfigurationProperties(); Map<String, Object> configs = admin.getConfigurationProperties();
// common // common
assertThat(configs.get(AdminClientConfig.CLIENT_ID_CONFIG)).isEqualTo("cid"); assertThat(configs).containsEntry(AdminClientConfig.CLIENT_ID_CONFIG, "cid");
// admin // admin
assertThat(configs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL"); assertThat(configs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
assertThat(configs.get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)).isEqualTo("p4"); assertThat(configs).containsEntry(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "p4");
assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "ksLocP"); .endsWith(File.separator + "ksLocP");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)).isEqualTo("p5"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "p5");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, "PKCS12");
assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "tsLocP"); .endsWith(File.separator + "tsLocP");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).isEqualTo("p6"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "p6");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "PKCS12");
assertThat(configs.get(SslConfigs.SSL_PROTOCOL_CONFIG)).isEqualTo("TLSv1.2"); assertThat(configs).containsEntry(SslConfigs.SSL_PROTOCOL_CONFIG, "TLSv1.2");
assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty(); assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty();
assertThat(configs.get("foo.bar.baz")).isEqualTo("qux.fiz.buz"); assertThat(configs).containsEntry("foo.bar.baz", "qux.fiz.buz");
assertThat(configs.get("fiz.buz")).isEqualTo("fix.fox"); assertThat(configs).containsEntry("fiz.buz", "fix.fox");
assertThat(admin).hasFieldOrPropertyWithValue("fatalIfBrokerNotAvailable", true); assertThat(admin).hasFieldOrPropertyWithValue("fatalIfBrokerNotAvailable", true);
assertThat(admin).hasFieldOrPropertyWithValue("modifyTopicConfigs", true); assertThat(admin).hasFieldOrPropertyWithValue("modifyTopicConfigs", true);
}); });
@ -263,24 +263,24 @@ class KafkaAutoConfigurationTests {
.asProperties(); .asProperties();
assertThat((List<String>) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) assertThat((List<String>) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG))
.containsExactly("localhost:9092", "localhost:9093"); .containsExactly("localhost:9092", "localhost:9093");
assertThat(configs.get(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG)).isEqualTo(1024); assertThat(configs).containsEntry(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 1024);
assertThat(configs.get(StreamsConfig.CLIENT_ID_CONFIG)).isEqualTo("override"); assertThat(configs).containsEntry(StreamsConfig.CLIENT_ID_CONFIG, "override");
assertThat(configs.get(StreamsConfig.REPLICATION_FACTOR_CONFIG)).isEqualTo(2); assertThat(configs).containsEntry(StreamsConfig.REPLICATION_FACTOR_CONFIG, 2);
assertThat(configs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL"); assertThat(configs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
assertThat(configs.get(StreamsConfig.STATE_DIR_CONFIG)).isEqualTo("/tmp/state"); assertThat(configs).containsEntry(StreamsConfig.STATE_DIR_CONFIG, "/tmp/state");
assertThat(configs.get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)).isEqualTo("p7"); assertThat(configs).containsEntry(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "p7");
assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "ksLocP"); .endsWith(File.separator + "ksLocP");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)).isEqualTo("p8"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "p8");
assertThat(configs.get(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, "PKCS12");
assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG)) assertThat((String) configs.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG))
.endsWith(File.separator + "tsLocP"); .endsWith(File.separator + "tsLocP");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).isEqualTo("p9"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "p9");
assertThat(configs.get(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG)).isEqualTo("PKCS12"); assertThat(configs).containsEntry(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "PKCS12");
assertThat(configs.get(SslConfigs.SSL_PROTOCOL_CONFIG)).isEqualTo("TLSv1.2"); assertThat(configs).containsEntry(SslConfigs.SSL_PROTOCOL_CONFIG, "TLSv1.2");
assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty(); assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).isEmpty();
assertThat(configs.get("foo.bar.baz")).isEqualTo("qux.fiz.buz"); assertThat(configs).containsEntry("foo.bar.baz", "qux.fiz.buz");
assertThat(configs.get("fiz.buz")).isEqualTo("fix.fox"); assertThat(configs).containsEntry("fiz.buz", "fix.fox");
assertThat(context.getBean(KafkaStreamsDefaultConfiguration.DEFAULT_STREAMS_BUILDER_BEAN_NAME)) assertThat(context.getBean(KafkaStreamsDefaultConfiguration.DEFAULT_STREAMS_BUILDER_BEAN_NAME))
.isNotNull(); .isNotNull();
}); });
@ -300,7 +300,7 @@ class KafkaAutoConfigurationTests {
.asProperties(); .asProperties();
assertThat((List<String>) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) assertThat((List<String>) configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG))
.containsExactly("localhost:9092", "localhost:9093"); .containsExactly("localhost:9092", "localhost:9093");
assertThat(configs.get(StreamsConfig.APPLICATION_ID_CONFIG)).isEqualTo("my-test-app"); assertThat(configs).containsEntry(StreamsConfig.APPLICATION_ID_CONFIG, "my-test-app");
}); });
} }
@ -316,9 +316,9 @@ class KafkaAutoConfigurationTests {
.getBean(KafkaStreamsDefaultConfiguration.DEFAULT_STREAMS_CONFIG_BEAN_NAME, .getBean(KafkaStreamsDefaultConfiguration.DEFAULT_STREAMS_CONFIG_BEAN_NAME,
KafkaStreamsConfiguration.class) KafkaStreamsConfiguration.class)
.asProperties(); .asProperties();
assertThat(configs.get(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) assertThat(configs).containsEntry(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG,
.isEqualTo("localhost:9094, localhost:9095"); "localhost:9094, localhost:9095");
assertThat(configs.get(StreamsConfig.APPLICATION_ID_CONFIG)).isEqualTo("test-id"); assertThat(configs).containsEntry(StreamsConfig.APPLICATION_ID_CONFIG, "test-id");
}); });
} }
@ -479,7 +479,7 @@ class KafkaAutoConfigurationTests {
assertThat(kafkaListenerContainerFactory.getConsumerFactory()).isEqualTo(consumerFactory); assertThat(kafkaListenerContainerFactory.getConsumerFactory()).isEqualTo(consumerFactory);
ContainerProperties containerProperties = kafkaListenerContainerFactory.getContainerProperties(); ContainerProperties containerProperties = kafkaListenerContainerFactory.getContainerProperties();
assertThat(containerProperties.getAckMode()).isEqualTo(AckMode.MANUAL); assertThat(containerProperties.getAckMode()).isEqualTo(AckMode.MANUAL);
assertThat(containerProperties.isAsyncAcks()).isEqualTo(true); assertThat(containerProperties.isAsyncAcks()).isTrue();
assertThat(containerProperties.getClientId()).isEqualTo("client"); assertThat(containerProperties.getClientId()).isEqualTo("client");
assertThat(containerProperties.getAckCount()).isEqualTo(123); assertThat(containerProperties.getAckCount()).isEqualTo(123);
assertThat(containerProperties.getAckTime()).isEqualTo(456L); assertThat(containerProperties.getAckTime()).isEqualTo(456L);
@ -672,10 +672,10 @@ class KafkaAutoConfigurationTests {
DefaultKafkaProducerFactory<?, ?> producerFactory = context DefaultKafkaProducerFactory<?, ?> producerFactory = context
.getBean(DefaultKafkaProducerFactory.class); .getBean(DefaultKafkaProducerFactory.class);
Map<String, Object> producerConfigs = producerFactory.getConfigurationProperties(); Map<String, Object> producerConfigs = producerFactory.getConfigurationProperties();
assertThat(producerConfigs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL"); assertThat(producerConfigs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
KafkaAdmin admin = context.getBean(KafkaAdmin.class); KafkaAdmin admin = context.getBean(KafkaAdmin.class);
Map<String, Object> configs = admin.getConfigurationProperties(); Map<String, Object> configs = admin.getConfigurationProperties();
assertThat(configs.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("PLAINTEXT"); assertThat(configs).containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "PLAINTEXT");
}); });
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save