Simplify AssertJ assertions and also make them more readable

See gh-33653
This commit is contained in:
Krzysztof Krason 2022-12-29 17:52:45 +01:00 committed by Moritz Halbritter
parent c9a2b2ab66
commit cf6493f65c
345 changed files with 1258 additions and 1292 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,7 +72,7 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
ConfigurationPropertiesReportEndpointWebExtension endpoint = context
.getBean(ConfigurationPropertiesReportEndpointWebExtension.class);
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()
.get("testProperties").getProperties();
assertThat(nestedProperties).isNotNull();
assertThat(nestedProperties.get("dbPassword")).isEqualTo(dbPassword);
assertThat(nestedProperties.get("myTestProperty")).isEqualTo(myTestProperty);
assertThat(nestedProperties).containsEntry("dbPassword", dbPassword);
assertThat(nestedProperties).containsEntry("myTestProperty", myTestProperty);
};
}

View File

@ -51,20 +51,20 @@ class DefaultEndpointObjectNameFactoryTests {
@Test
void generateObjectName() {
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
void generateObjectNameWithCapitalizedId() {
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
void generateObjectNameWithCustomDomain() {
this.properties.setDomain("com.example.acme");
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
@ -77,7 +77,7 @@ class DefaultEndpointObjectNameFactoryTests {
ExposableJmxEndpoint endpoint = endpoint(EndpointId.of("test"));
String id = ObjectUtils.getIdentityHexString(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
@ -96,8 +96,7 @@ class DefaultEndpointObjectNameFactoryTests {
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")));
ObjectName objectName = generateObjectName(endpoint(EndpointId.of("test")));
assertThat(objectName.toString())
.isEqualTo("org.springframework.boot:type=Endpoint,name=Test,context=testContext");
assertThat(objectName).hasToString("org.springframework.boot:type=Endpoint,name=Test,context=testContext");
}

View File

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

View File

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

View File

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

View File

@ -118,7 +118,7 @@ class MetricsAutoConfigurationIntegrationTests {
new ApplicationContextRunner().with(MetricsRun.limitedTo(GraphiteMetricsExportAutoConfiguration.class,
JmxMetricsExportAutoConfiguration.class)).run((context) -> {
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);
Set<MeterRegistry> registries = ((CompositeMeterRegistry) composite).getRegistries();
assertThat(registries).hasSize(2);

View File

@ -81,7 +81,7 @@ class MetricsAutoConfigurationMeterRegistryPostProcessorIntegrationTests {
Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class);
assertThat(registriesByName).hasSize(1);
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.");
Map<String, MeterRegistry> registriesByName = context.getBeansOfType(MeterRegistry.class);
assertThat(registriesByName).hasSize(3);
registriesByName.forEach((name,
registry) -> assertThat(
registry.get("logback.events").tag("level", "error").counter().count())
.isEqualTo(1));
registriesByName
.forEach((name,
registry) -> assertThat(
registry.get("logback.events").tag("level", "error").counter().count())
.isOne());
});
}

View File

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

View File

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

View File

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

View File

@ -140,7 +140,7 @@ class HibernateMetricsAutoConfigurationTests {
() -> (builder) -> builder.setBootstrapExecutor(new SimpleAsyncTaskExecutor()))
.run((context) -> {
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);
registry.get("hibernate.statements").tags("entityManagerFactory", "entityManagerFactory").meter();
});

View File

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

View File

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

View File

@ -149,7 +149,7 @@ class ObservationAutoConfigurationTests {
// When a DefaultMeterObservationHandler is registered, every stopped
// Observation leads to a timer
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(ObservationHandler.class);
});
@ -170,7 +170,7 @@ class ObservationAutoConfigurationTests {
// This isn't allowed by ObservationPredicates.customPredicate
Observation.start("observation2", observationRegistry).stop();
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())
.isInstanceOf(MeterNotFoundException.class);
});

View File

@ -117,7 +117,7 @@ class WebFluxObservationAutoConfigurationTests {
ObservationAutoConfiguration.class, WebFluxAutoConfiguration.class))
.withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((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'");
});
}
@ -132,7 +132,7 @@ class WebFluxObservationAutoConfigurationTests {
"management.metrics.web.server.request.metric-name=my.http.server.requests")
.run((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'");
});
}
@ -146,7 +146,7 @@ class WebFluxObservationAutoConfigurationTests {
"management.observations.http.server.requests.name=my.http.server.requests")
.run((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'");
});
}

View File

@ -151,7 +151,7 @@ class WebMvcObservationAutoConfigurationTests {
ObservationAutoConfiguration.class, WebMvcAutoConfiguration.class))
.withPropertyValues("management.metrics.web.server.max-uri-tags=2").run((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'");
});
}
@ -166,7 +166,7 @@ class WebMvcObservationAutoConfigurationTests {
"management.metrics.web.server.request.metric-name=my.http.server.requests")
.run((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'");
});
}
@ -180,7 +180,7 @@ class WebMvcObservationAutoConfigurationTests {
"management.observations.http.server.requests.name=my.http.server.requests")
.run((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'");
});
}

View File

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

View File

@ -137,7 +137,7 @@ class BraveAutoConfigurationTests {
void shouldSupplyB3PropagationFactoryViaProperty() {
this.contextRunner.withPropertyValues("management.tracing.propagation.type=B3").run((context) -> {
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);
});
}
@ -168,7 +168,7 @@ class BraveAutoConfigurationTests {
this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false",
"management.tracing.propagation.type=B3").run((context) -> {
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);
});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull();
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();
assertThat(map).isNotNull();
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();
assertThat(map).isNotNull();
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();
assertThat(map).isNotNull();
assertThat(map).hasSize(3);
assertThat(map.get("address")).isEqualTo("192.168.1.10");
assertThat(map).containsEntry("address", "192.168.1.10");
});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -47,7 +47,7 @@ class InfluxDbHealthIndicatorTests {
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
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();
}

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ class LdapHealthIndicatorTests {
LdapHealthIndicator healthIndicator = new LdapHealthIndicator(ldapTemplate);
Health health = healthIndicator.health();
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());
}

View File

@ -66,7 +66,7 @@ class MailHealthIndicatorTests {
given(this.mailSender.getProtocol()).willReturn("success");
Health health = this.indicator.health();
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
@ -74,10 +74,10 @@ class MailHealthIndicatorTests {
willThrow(new MessagingException("A test exception")).given(this.mailSender).testConnection();
Health health = this.indicator.health();
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");
assertThat(errorMessage).isNotNull();
assertThat(errorMessage.toString().contains("A test exception")).isTrue();
assertThat(errorMessage.toString()).contains("A test exception");
}
static class SuccessTransport extends Transport {

View File

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

View File

@ -86,7 +86,7 @@ class MetricsRepositoryMethodInvocationListenerTests {
}
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) {

View File

@ -46,7 +46,7 @@ class MongoHealthIndicatorTests {
MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);
Health health = healthIndicator.health();
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(mongoTemplate).should().executeCommand("{ isMaster: 1 }");
}

View File

@ -50,7 +50,7 @@ class MongoReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("maxWireVersion");
assertThat(h.getDetails().get("maxWireVersion")).isEqualTo(10);
assertThat(h.getDetails()).containsEntry("maxWireVersion", 10);
}).verifyComplete();
}
@ -65,7 +65,7 @@ class MongoReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
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();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -696,7 +696,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
Cache foo = manager.getCache("foo");
foo.get("1");
// 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");
Cache foo = manager.getCache("foo");
foo.get("1");
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(1L);
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isOne();
}
private CouchbaseCacheConfiguration getDefaultCouchbaseCacheConfiguration(CouchbaseCacheManager cacheManager) {

View File

@ -56,14 +56,14 @@ class CacheManagerCustomizersTests {
list.add(new TestConcurrentMapCacheManagerCustomizer());
CacheManagerCustomizers customizers = new CacheManagerCustomizers(list);
customizers.customize(mock(CacheManager.class));
assertThat(list.get(0).getCount()).isEqualTo(1);
assertThat(list.get(1).getCount()).isEqualTo(0);
assertThat(list.get(0).getCount()).isOne();
assertThat(list.get(1).getCount()).isZero();
customizers.customize(mock(ConcurrentMapCacheManager.class));
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));
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> {

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ class CouchbasePropertiesTests {
@Test
void ioHaveConsistentDefaults() {
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.getIdleHttpConnectionTimeout()).isEqualTo(IoConfig.DEFAULT_IDLE_HTTP_CONNECTION_TIMEOUT);
}

View File

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

View File

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

View File

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

View File

@ -272,7 +272,7 @@ class FlywayAutoConfigurationTests {
.withPropertyValues("spring.flyway.schemas:public").run((context) -> {
assertThat(context).hasSingleBean(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]");
});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -423,7 +423,7 @@ class IntegrationAutoConfigurationTests {
.run((context) -> {
assertThat(context).hasSingleBean(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.getTrigger()).asInstanceOf(InstanceOfAssertFactories.type(CronTrigger.class))
.satisfies((trigger) -> assertThat(trigger.getExpression()).isEqualTo("* * * ? * *"));

View File

@ -102,7 +102,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
new IntegrationPropertiesEnvironmentPostProcessor().registerIntegrationPropertiesPropertySource(environment,
resource);
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;
assertThat(originLookup.getOrigin("spring.integration.channel.auto-create"))
.satisfies(textOrigin(resource, 0, 39));

View File

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

View File

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

View File

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

View File

@ -150,7 +150,7 @@ class JdbcTemplateAutoConfigurationTests {
this.contextRunner.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class))
.withUserConfiguration(DataSourceInitializationValidator.class).run((context) -> {
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")
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class)).run((context) -> {
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) -> {
assertThat(context).hasNotFailed();
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")
.withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class)).run((context) -> {
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) -> {
assertThat(context).hasNotFailed();
assertThat(context.getBean(JdbcTemplate.class)).isNotNull();
assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isEqualTo(0);
assertThat(context.getBean(NamedParameterDataSourceMigrationValidator.class).count).isZero();
});
}

View File

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

View File

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

View File

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

View File

@ -77,7 +77,7 @@ class ArtemisAutoConfigurationTests {
assertThat(connectionFactory.getTargetConnectionFactory()).isInstanceOf(ActiveMQConnectionFactory.class);
assertThat(connectionFactory.isCacheConsumers()).isFalse();
assertThat(connectionFactory.isCacheProducers()).isTrue();
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1);
assertThat(connectionFactory.getSessionCacheSize()).isOne();
});
}
@ -374,7 +374,7 @@ class ArtemisAutoConfigurationTests {
String host, int port) {
TransportConfiguration transportConfig = getSingleTransportConfiguration(connectionFactory);
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");
if (transportConfigPort instanceof String portString) {
transportConfigPort = Integer.parseInt(portString);

View File

@ -171,7 +171,7 @@ class JooqAutoConfigurationTests {
@Override
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);
}
}

View File

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

View File

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