diff --git a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java index ef949ac8b0..80cf310e10 100644 --- a/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java +++ b/ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/sonatype/SonatypeServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,7 +132,7 @@ class SonatypeServiceTests { .andRespond(withSuccess()); this.service.publish(getReleaseInfo(), artifactsRoot); this.server.verify(); - assertThat(uploadRequestsMatcher.candidates).hasSize(0); + assertThat(uploadRequestsMatcher.candidates).isEmpty(); } } @@ -184,7 +184,7 @@ class SonatypeServiceTests { .isThrownBy(() -> this.service.publish(getReleaseInfo(), artifactsRoot)) .withMessage("Close failed"); this.server.verify(); - assertThat(uploadRequestsMatcher.candidates).hasSize(0); + assertThat(uploadRequestsMatcher.candidates).isEmpty(); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityServiceTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityServiceTests.java index 29258b9f20..ac73c0fc21 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityServiceTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityServiceTests.java @@ -51,13 +51,11 @@ class ReactiveCloudFoundrySecurityServiceTests { private MockWebServer server; - private WebClient.Builder builder; - @BeforeEach void setup() { this.server = new MockWebServer(); - this.builder = WebClient.builder().baseUrl(this.server.url("/").toString()); - this.securityService = new ReactiveCloudFoundrySecurityService(this.builder, CLOUD_CONTROLLER, false); + WebClient.Builder builder = WebClient.builder().baseUrl(this.server.url("/").toString()); + this.securityService = new ReactiveCloudFoundrySecurityService(builder, CLOUD_CONTROLLER, false); } @AfterEach @@ -183,7 +181,7 @@ class ReactiveCloudFoundrySecurityServiceTests { response.setHeader("Content-Type", "application/json"); }); StepVerifier.create(this.securityService.fetchTokenKeys()) - .consumeNextWith((tokenKeys) -> assertThat(tokenKeys).hasSize(0)) + .consumeNextWith((tokenKeys) -> assertThat(tokenKeys).isEmpty()) .expectComplete() .verify(); expectRequest((request) -> assertThat(request.getPath()).isEqualTo("/my-cloud-controller.com/info")); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java index 6b04e877c6..87a87f90c4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java @@ -33,6 +33,7 @@ import org.junit.jupiter.params.provider.EnumSource.Mode; import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.sql.init.DatabaseInitializationSettings; import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.test.util.ReflectionTestUtils; @@ -76,7 +77,7 @@ class BatchDataSourceScriptDatabaseInitializerTests { DatabaseInitializationSettings settings = BatchDataSourceScriptDatabaseInitializer.getSettings(dataSource, properties.getJdbc()); List schemaLocations = settings.getSchemaLocations(); - assertThat(schemaLocations) + assertThat(schemaLocations).isNotEmpty() .allSatisfy((location) -> assertThat(resourceLoader.getResource(location).exists()).isTrue()); } @@ -85,7 +86,7 @@ class BatchDataSourceScriptDatabaseInitializerTests { PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); List schemaNames = Stream .of(resolver.getResources("classpath:org/springframework/batch/core/schema-*.sql")) - .map((resource) -> resource.getFilename()) + .map(Resource::getFilename) .filter((resourceName) -> !resourceName.contains("-drop-")) .toList(); assertThat(schemaNames).containsExactlyInAnyOrder("schema-derby.sql", "schema-sqlserver.sql", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java index 2e130ff8c9..fc1df6ace2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java @@ -164,7 +164,7 @@ class ConditionEvaluationReportTests { void springBootConditionPopulatesReport() { ConditionEvaluationReport report = ConditionEvaluationReport .get(new AnnotationConfigApplicationContext(Config.class).getBeanFactory()); - assertThat(report.getConditionAndOutcomesBySource().size()).isNotZero(); + assertThat(report.getConditionAndOutcomesBySource()).isNotEmpty(); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanTests.java index da64265c30..9ca96314e9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanTests.java @@ -155,7 +155,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(FactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -163,7 +163,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ScanBean.class)).hasToString("fromFactory")); } @Test @@ -171,7 +171,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodWithArgumentsConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ScanBean.class)).hasToString("fromFactory")); } @Test @@ -180,7 +180,7 @@ class ConditionalOnMissingBeanTests { .withUserConfiguration(FactoryBeanWithBeanMethodArgumentsConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) .withPropertyValues("theValue=foo") - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -188,7 +188,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(ConcreteFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -205,7 +205,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(RegisteredFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -213,7 +213,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(NonspecificFactoryBeanClassAttributeConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -221,7 +221,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(NonspecificFactoryBeanStringAttributeConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test @@ -229,7 +229,7 @@ class ConditionalOnMissingBeanTests { this.contextRunner .withUserConfiguration(FactoryBeanXmlConfiguration.class, ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); + .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory")); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java index 9d86809998..7a65682b93 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java @@ -119,7 +119,7 @@ class ProjectInfoAutoConfigurationTests { @Test void buildPropertiesCustomInvalidLocation() { this.contextRunner.withPropertyValues("spring.info.build.location=classpath:/org/acme/no-build-info.properties") - .run((context) -> assertThat(context.getBeansOfType(BuildProperties.class)).hasSize(0)); + .run((context) -> assertThat(context.getBeansOfType(BuildProperties.class)).isEmpty()); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomObjectMapperProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomObjectMapperProviderTests.java index 7cddc14bfe..fe823f0954 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomObjectMapperProviderTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomObjectMapperProviderTests.java @@ -60,8 +60,8 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests { @Test void contextLoads() { ResponseEntity response = this.restTemplate.getForEntity("/rest/message", String.class); - assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode()); - assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}"); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat("{\"subject\":\"Jersey\"}").isEqualTo(response.getBody()); } @MinimalWebConfiguration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationObjectMapperProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationObjectMapperProviderTests.java index e133626346..59cc5167b3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationObjectMapperProviderTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationObjectMapperProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class JerseyAutoConfigurationObjectMapperProviderTests { @Test void responseIsSerializedUsingAutoConfiguredObjectMapper() { ResponseEntity response = this.restTemplate.getForEntity("/rest/message", String.class); - assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode()); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}"); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQPropertiesTests.java index 07d84e900e..a839b4d03d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQPropertiesTests.java @@ -62,7 +62,7 @@ class ActiveMQPropertiesTests { ActiveMQConnectionFactory factory = createFactory(this.properties) .createConnectionFactory(ActiveMQConnectionFactory.class); assertThat(factory.isTrustAllPackages()).isFalse(); - assertThat(factory.getTrustedPackages().size()).isEqualTo(1); + assertThat(factory.getTrustedPackages()).hasSize(1); assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package"); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 1ecc2395be..7ccc5e12bf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -235,7 +235,7 @@ class WebMvcAutoConfigurationTests { @Test void resourceHandlerMappingDisabled() { this.contextRunner.withPropertyValues("spring.web.resources.add-mappings:false") - .run((context) -> assertThat(getResourceMappingLocations(context)).hasSize(0)); + .run((context) -> assertThat(getResourceMappingLocations(context)).isEmpty()); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java index 354fd1d7e3..35504c8926 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/ChangeableUrlsTests.java @@ -48,7 +48,7 @@ class ChangeableUrlsTests { @Test void directoryUrl() throws Exception { URL url = makeUrl("myproject"); - assertThat(ChangeableUrls.fromUrls(url).size()).isOne(); + assertThat(ChangeableUrls.fromUrls(url)).hasSize(1); } @Test diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java index 308642994c..059bc27443 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,6 @@ import org.springframework.core.Ordered; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.nullValue; import static org.mockito.Mockito.mock; /** @@ -103,7 +102,7 @@ class RestartApplicationListenerTests { SpringApplication application = new SpringApplication(); ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class); listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS)); - assertThat(Restarter.getInstance()).isNotEqualTo(nullValue()); + assertThat(Restarter.getInstance()).isNotNull(); assertThat(Restarter.getInstance().isFinished()).isFalse(); listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context)); if (failed) { diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/core/DockerComposeFileTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/core/DockerComposeFileTests.java index 4d1692e247..02bab15eb4 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/core/DockerComposeFileTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/core/DockerComposeFileTests.java @@ -106,7 +106,7 @@ class DockerComposeFileTests { FileCopyUtils.copy(new byte[0], file); DockerComposeFile composeFile = DockerComposeFile.of(file); assertThat(composeFile).isNotNull(); - assertThat(composeFile.toString()).isEqualTo(file.getCanonicalPath()); + assertThat(composeFile).hasToString(file.getCanonicalPath()); } @Test diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraDockerComposeConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraDockerComposeConnectionDetailsFactoryIntegrationTests.java index 5c7bd51379..8df562e231 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -42,7 +42,7 @@ class CassandraDockerComposeConnectionDetailsFactoryIntegrationTests extends Abs void runCreatesConnectionDetails() { CassandraConnectionDetails connectionDetails = run(CassandraConnectionDetails.class); List contactPoints = connectionDetails.getContactPoints(); - assertThat(contactPoints.size()).isEqualTo(1); + assertThat(contactPoints).hasSize(1); Node node = contactPoints.get(0); assertThat(node.host()).isNotNull(); assertThat(node.port()).isGreaterThan(0); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchiveManifestTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchiveManifestTests.java index 31cd8a768c..8f0eaccd84 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchiveManifestTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchiveManifestTests.java @@ -52,7 +52,7 @@ class ImageArchiveManifestTests extends AbstractJsonTests { String content = "[{\"Layers\": []}]"; ImageArchiveManifest manifest = new ImageArchiveManifest(getObjectMapper().readTree(content)); assertThat(manifest.getEntries()).hasSize(1); - assertThat(manifest.getEntries().get(0).getLayers()).hasSize(0); + assertThat(manifest.getEntries().get(0).getLayers()).isEmpty(); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java index 4f45a734cb..9a2b1aeed8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java @@ -111,15 +111,16 @@ class PropertyDescriptorResolverTests { void propertiesWithDeducedConstructorBinding() { process(ImmutableDeducedConstructorBindingProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag"))); - process(ImmutableDeducedConstructorBindingProperties.class, properties((stream) -> assertThat(stream) - .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); + process(ImmutableDeducedConstructorBindingProperties.class, + properties((stream) -> assertThat(stream).isNotEmpty() + .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); } @Test void propertiesWithConstructorWithConstructorBinding() { process(ImmutableSimpleProperties.class, propertyNames( (stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator", "counter"))); - process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream) + process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream).isNotEmpty() .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); } @@ -127,14 +128,14 @@ class PropertyDescriptorResolverTests { void propertiesWithConstructorAndClassConstructorBinding() { process(ImmutableClassConstructorBindingProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); - process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream) + process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream).isNotEmpty() .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); } @Test void propertiesWithAutowiredConstructor() { process(AutowiredProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName"))); - process(AutowiredProperties.class, properties((stream) -> assertThat(stream) + process(AutowiredProperties.class, properties((stream) -> assertThat(stream).isNotEmpty() .allMatch((predicate) -> predicate instanceof JavaBeanPropertyDescriptor))); } @@ -142,7 +143,7 @@ class PropertyDescriptorResolverTests { void propertiesWithMultiConstructor() { process(ImmutableMultiConstructorProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); - process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream) + process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream).isNotEmpty() .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index ec338420f1..f4eceac89a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -488,7 +488,7 @@ abstract class AbstractBootArchiveTests { void jarWhenLayersDisabledShouldNotContainLayersIndex() throws IOException { List entryNames = getEntryNames( createLayeredJar((configuration) -> configuration.getEnabled().set(false))); - assertThat(entryNames).doesNotContain(this.indexPath + "layers.idx"); + assertThat(entryNames).isNotEmpty().doesNotContain(this.indexPath + "layers.idx"); } @Test @@ -605,7 +605,7 @@ abstract class AbstractBootArchiveTests { void whenArchiveIsLayeredAndIncludeLayerToolsIsFalseThenLayerToolsAreNotAddedToTheJar() throws IOException { List entryNames = getEntryNames( createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false))); - assertThat(entryNames) + assertThat(entryNames).isNotEmpty() .doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar"); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index 1188dd0ba8..b37a99183a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -220,7 +220,7 @@ class JarFileTests { @Test void size() throws Exception { try (ZipFile zip = new ZipFile(this.rootJarFile)) { - assertThat(this.jarFile.size()).isEqualTo(zip.size()); + assertThat(this.jarFile).hasSize(zip.size()); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java index a63c056fbb..f7139ad750 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorTests.java @@ -108,7 +108,7 @@ class ConfigDataEnvironmentPostProcessorTests { TestConfigDataEnvironmentUpdateListener listener = new TestConfigDataEnvironmentUpdateListener(); ConfigDataEnvironmentPostProcessor.applyTo(this.environment, null, null, Collections.singleton("dev"), listener); - assertThat(this.environment.getPropertySources().size()).isGreaterThan(before); + assertThat(this.environment.getPropertySources()).hasSizeGreaterThan(before); assertThat(this.environment.getActiveProfiles()).containsExactly("dev"); assertThat(listener.getAddedPropertySources()).isNotEmpty(); assertThat(listener.getProfiles().getActive()).containsExactly("dev"); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java index 552bbbc2ef..5907688999 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java @@ -54,7 +54,7 @@ class ConfigurationPropertySourcesTests { sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568"))); int size = sources.size(); ConfigurationPropertySources.attach(environment); - assertThat(sources.size()).isEqualTo(size + 1); + assertThat(sources).hasSize(size + 1); PropertyResolver resolver = new PropertySourcesPropertyResolver(sources); assertThat(resolver.getProperty("server.port")).isEqualTo("1234"); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java index 0ecf890c9f..dbc0bff4e5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java @@ -62,14 +62,14 @@ class SampleOAuth2AuthorizationServerApplicationTests { assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); OidcProviderConfiguration config = OidcProviderConfiguration.withClaims(entity.getBody()).build(); - assertThat(config.getIssuer().toString()).isEqualTo("https://provider.com"); - assertThat(config.getAuthorizationEndpoint().toString()).isEqualTo("https://provider.com/authorize"); - assertThat(config.getTokenEndpoint().toString()).isEqualTo("https://provider.com/token"); - assertThat(config.getJwkSetUrl().toString()).isEqualTo("https://provider.com/jwks"); - assertThat(config.getTokenRevocationEndpoint().toString()).isEqualTo("https://provider.com/revoke"); - assertThat(config.getEndSessionEndpoint().toString()).isEqualTo("https://provider.com/logout"); - assertThat(config.getTokenIntrospectionEndpoint().toString()).isEqualTo("https://provider.com/introspect"); - assertThat(config.getUserInfoEndpoint().toString()).isEqualTo("https://provider.com/user"); + assertThat(config.getIssuer()).hasToString("https://provider.com"); + assertThat(config.getAuthorizationEndpoint()).hasToString("https://provider.com/authorize"); + assertThat(config.getTokenEndpoint()).hasToString("https://provider.com/token"); + assertThat(config.getJwkSetUrl()).hasToString("https://provider.com/jwks"); + assertThat(config.getTokenRevocationEndpoint()).hasToString("https://provider.com/revoke"); + assertThat(config.getEndSessionEndpoint()).hasToString("https://provider.com/logout"); + assertThat(config.getTokenIntrospectionEndpoint()).hasToString("https://provider.com/introspect"); + assertThat(config.getUserInfoEndpoint()).hasToString("https://provider.com/user"); // OIDC Client Registration is disabled by default assertThat(config.getClientRegistrationEndpoint()).isNull(); } @@ -82,12 +82,12 @@ class SampleOAuth2AuthorizationServerApplicationTests { OAuth2AuthorizationServerMetadata config = OAuth2AuthorizationServerMetadata.withClaims(entity.getBody()) .build(); - assertThat(config.getIssuer().toString()).isEqualTo("https://provider.com"); - assertThat(config.getAuthorizationEndpoint().toString()).isEqualTo("https://provider.com/authorize"); - assertThat(config.getTokenEndpoint().toString()).isEqualTo("https://provider.com/token"); - assertThat(config.getJwkSetUrl().toString()).isEqualTo("https://provider.com/jwks"); - assertThat(config.getTokenRevocationEndpoint().toString()).isEqualTo("https://provider.com/revoke"); - assertThat(config.getTokenIntrospectionEndpoint().toString()).isEqualTo("https://provider.com/introspect"); + assertThat(config.getIssuer()).hasToString("https://provider.com"); + assertThat(config.getAuthorizationEndpoint()).hasToString("https://provider.com/authorize"); + assertThat(config.getTokenEndpoint()).hasToString("https://provider.com/token"); + assertThat(config.getJwkSetUrl()).hasToString("https://provider.com/jwks"); + assertThat(config.getTokenRevocationEndpoint()).hasToString("https://provider.com/revoke"); + assertThat(config.getTokenIntrospectionEndpoint()).hasToString("https://provider.com/introspect"); // OIDC Client Registration is disabled by default assertThat(config.getClientRegistrationEndpoint()).isNull(); }