Polish tests

pull/36455/head
Moritz Halbritter 1 year ago
parent 4ea3c75331
commit 7bb337aeb1

@ -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();
}
}

@ -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"));

@ -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<String> 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<String> 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",

@ -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

@ -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

@ -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

@ -60,8 +60,8 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
@Test
void contextLoads() {
ResponseEntity<String> 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

@ -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<String> 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\"}");
}

@ -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");
}

@ -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

@ -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

@ -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) {

@ -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

@ -42,7 +42,7 @@ class CassandraDockerComposeConnectionDetailsFactoryIntegrationTests extends Abs
void runCreatesConnectionDetails() {
CassandraConnectionDetails connectionDetails = run(CassandraConnectionDetails.class);
List<Node> 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);

@ -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

@ -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)));
}

@ -488,7 +488,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
void jarWhenLayersDisabledShouldNotContainLayersIndex() throws IOException {
List<String> 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<T extends Jar & BootArchive> {
void whenArchiveIsLayeredAndIncludeLayerToolsIsFalseThenLayerToolsAreNotAddedToTheJar() throws IOException {
List<String> entryNames = getEntryNames(
createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false)));
assertThat(entryNames)
assertThat(entryNames).isNotEmpty()
.doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar");
}

@ -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());
}
}

@ -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");

@ -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");
}

@ -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();
}

Loading…
Cancel
Save