Merge pull request #28862 from scordio
* pr/28862: Update copyright year of changed files Simplify AssertJ usage Closes gh-28862
This commit is contained in:
commit
40f5cffd7d
|
@ -233,7 +233,7 @@ class CloudFoundryActuatorAutoConfigurationTests {
|
||||||
ExposableWebEndpoint endpoint = endpoints.iterator().next();
|
ExposableWebEndpoint endpoint = endpoints.iterator().next();
|
||||||
assertThat(endpoint.getOperations()).hasSize(2);
|
assertThat(endpoint.getOperations()).hasSize(2);
|
||||||
WebOperation webOperation = findOperationWithRequestPath(endpoint, "health");
|
WebOperation webOperation = findOperationWithRequestPath(endpoint, "health");
|
||||||
assertThat(webOperation).extracting("invoker").extracting("target")
|
assertThat(webOperation).extracting("invoker.target")
|
||||||
.isInstanceOf(CloudFoundryHealthEndpointWebExtension.class);
|
.isInstanceOf(CloudFoundryHealthEndpointWebExtension.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.springframework.boot.actuate.endpoint.OperationArgumentResolver;
|
||||||
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
||||||
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.as;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
|
@ -115,8 +116,7 @@ class CachingOperationInvokerTests {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
}
|
}
|
||||||
invokeWithUniquePrincipal(invoker);
|
invokeWithUniquePrincipal(invoker);
|
||||||
assertThat(invoker).extracting("cachedResponses").asInstanceOf(InstanceOfAssertFactories.MAP)
|
assertThat(invoker).extracting("cachedResponses", as(InstanceOfAssertFactories.MAP)).hasSizeLessThan(count);
|
||||||
.hasSizeLessThan(count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeWithUniquePrincipal(CachingOperationInvoker invoker) {
|
private void invokeWithUniquePrincipal(CachingOperationInvoker invoker) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -58,7 +58,7 @@ class MetricsWebClientCustomizerTests {
|
||||||
this.clientBuilder.filters((filters) -> assertThat(filters).hasSize(1));
|
this.clientBuilder.filters((filters) -> assertThat(filters).hasSize(1));
|
||||||
this.customizer.customize(this.clientBuilder);
|
this.customizer.customize(this.clientBuilder);
|
||||||
this.clientBuilder.filters(
|
this.clientBuilder.filters(
|
||||||
(filters) -> assertThat(filters).hasSize(1).first().isInstanceOf(MetricsWebClientFilterFunction.class));
|
(filters) -> assertThat(filters).singleElement().isInstanceOf(MetricsWebClientFilterFunction.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.as;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ class CouchbaseAutoConfigurationTests {
|
||||||
expectedModuleIds.add(new JsonValueModule().getTypeId());
|
expectedModuleIds.add(new JsonValueModule().getTypeId());
|
||||||
JsonSerializer serializer = env.jsonSerializer();
|
JsonSerializer serializer = env.jsonSerializer();
|
||||||
assertThat(serializer).extracting("wrapped").isInstanceOf(JacksonJsonSerializer.class)
|
assertThat(serializer).extracting("wrapped").isInstanceOf(JacksonJsonSerializer.class)
|
||||||
.extracting("mapper").asInstanceOf(InstanceOfAssertFactories.type(ObjectMapper.class))
|
.extracting("mapper", as(InstanceOfAssertFactories.type(ObjectMapper.class)))
|
||||||
.extracting(ObjectMapper::getRegisteredModuleIds).isEqualTo(expectedModuleIds);
|
.extracting(ObjectMapper::getRegisteredModuleIds).isEqualTo(expectedModuleIds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,8 +276,8 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests {
|
||||||
void whenMaxInMemorySizeIsConfiguredThenUnderlyingWebClientHasCustomMaxInMemorySize(String prefix) {
|
void whenMaxInMemorySizeIsConfiguredThenUnderlyingWebClientHasCustomMaxInMemorySize(String prefix) {
|
||||||
this.contextRunner.withPropertyValues(prefix + "max-in-memory-size=1MB").run((context) -> {
|
this.contextRunner.withPropertyValues(prefix + "max-in-memory-size=1MB").run((context) -> {
|
||||||
WebClient client = configureWebClient(context.getBean(ClientConfiguration.class).getClientConfigurers());
|
WebClient client = configureWebClient(context.getBean(ClientConfiguration.class).getClientConfigurers());
|
||||||
assertThat(client).extracting("exchangeFunction").extracting("strategies").extracting("codecConfigurer")
|
assertThat(client).extracting("exchangeFunction.strategies.codecConfigurer.defaultCodecs")
|
||||||
.extracting("defaultCodecs").asInstanceOf(InstanceOfAssertFactories.type(DefaultCodecConfig.class))
|
.asInstanceOf(InstanceOfAssertFactories.type(DefaultCodecConfig.class))
|
||||||
.extracting(DefaultCodecConfig::maxInMemorySize).isEqualTo(1024 * 1024);
|
.extracting(DefaultCodecConfig::maxInMemorySize).isEqualTo(1024 * 1024);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,8 +161,8 @@ class ElasticsearchRestClientAutoConfigurationTests {
|
||||||
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
||||||
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
||||||
.containsExactly("http://localhost:9200");
|
.containsExactly("http://localhost:9200");
|
||||||
assertThat(client).extracting("client")
|
assertThat(client)
|
||||||
.extracting("credentialsProvider", InstanceOfAssertFactories.type(CredentialsProvider.class))
|
.extracting("client.credentialsProvider", InstanceOfAssertFactories.type(CredentialsProvider.class))
|
||||||
.satisfies((credentialsProvider) -> {
|
.satisfies((credentialsProvider) -> {
|
||||||
Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 9200));
|
Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 9200));
|
||||||
assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user");
|
assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user");
|
||||||
|
@ -177,8 +177,8 @@ class ElasticsearchRestClientAutoConfigurationTests {
|
||||||
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
||||||
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
||||||
.containsExactly("http://localhost:9200");
|
.containsExactly("http://localhost:9200");
|
||||||
assertThat(client).extracting("client")
|
assertThat(client)
|
||||||
.extracting("credentialsProvider", InstanceOfAssertFactories.type(CredentialsProvider.class))
|
.extracting("client.credentialsProvider", InstanceOfAssertFactories.type(CredentialsProvider.class))
|
||||||
.satisfies((credentialsProvider) -> {
|
.satisfies((credentialsProvider) -> {
|
||||||
Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 9200));
|
Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 9200));
|
||||||
assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user");
|
assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user");
|
||||||
|
@ -194,8 +194,8 @@ class ElasticsearchRestClientAutoConfigurationTests {
|
||||||
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
RestClient client = context.getBean(RestHighLevelClient.class).getLowLevelClient();
|
||||||
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString))
|
||||||
.containsExactly("http://localhost:9200", "http://localhost:9201");
|
.containsExactly("http://localhost:9200", "http://localhost:9201");
|
||||||
assertThat(client).extracting("client")
|
assertThat(client)
|
||||||
.extracting("credentialsProvider",
|
.extracting("client.credentialsProvider",
|
||||||
InstanceOfAssertFactories.type(CredentialsProvider.class))
|
InstanceOfAssertFactories.type(CredentialsProvider.class))
|
||||||
.satisfies((credentialsProvider) -> {
|
.satisfies((credentialsProvider) -> {
|
||||||
Credentials uriCredentials = credentialsProvider
|
Credentials uriCredentials = credentialsProvider
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -74,8 +74,7 @@ class SendGridAutoConfigurationTests {
|
||||||
loadContext("spring.sendgrid.api-key:SG.SECRET-API-KEY", "spring.sendgrid.proxy.host:localhost",
|
loadContext("spring.sendgrid.api-key:SG.SECRET-API-KEY", "spring.sendgrid.proxy.host:localhost",
|
||||||
"spring.sendgrid.proxy.port:5678");
|
"spring.sendgrid.proxy.port:5678");
|
||||||
SendGrid sendGrid = this.context.getBean(SendGrid.class);
|
SendGrid sendGrid = this.context.getBean(SendGrid.class);
|
||||||
assertThat(sendGrid).extracting("client").extracting("httpClient").extracting("routePlanner")
|
assertThat(sendGrid).extracting("client.httpClient.routePlanner").isInstanceOf(DefaultProxyRoutePlanner.class);
|
||||||
.isInstanceOf(DefaultProxyRoutePlanner.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadContext(String... environment) {
|
private void loadContext(String... environment) {
|
||||||
|
|
|
@ -190,8 +190,7 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
|
||||||
JdbcIndexedSessionRepository repository = validateSessionRepository(context,
|
JdbcIndexedSessionRepository repository = validateSessionRepository(context,
|
||||||
JdbcIndexedSessionRepository.class);
|
JdbcIndexedSessionRepository.class);
|
||||||
DataSource sessionDataSource = context.getBean("sessionDataSource", DataSource.class);
|
DataSource sessionDataSource = context.getBean("sessionDataSource", DataSource.class);
|
||||||
assertThat(repository).extracting("jdbcOperations").extracting("dataSource")
|
assertThat(repository).extracting("jdbcOperations.dataSource").isEqualTo(sessionDataSource);
|
||||||
.isEqualTo(sessionDataSource);
|
|
||||||
assertThat(context.getBean(JdbcSessionDataSourceScriptDatabaseInitializer.class))
|
assertThat(context.getBean(JdbcSessionDataSourceScriptDatabaseInitializer.class))
|
||||||
.hasFieldOrPropertyWithValue("dataSource", sessionDataSource);
|
.hasFieldOrPropertyWithValue("dataSource", sessionDataSource);
|
||||||
assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(
|
assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -160,7 +160,7 @@ class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTest
|
||||||
this.contextRunner.withUserConfiguration(SessionRepositoryConfiguration.class)
|
this.contextRunner.withUserConfiguration(SessionRepositoryConfiguration.class)
|
||||||
.withPropertyValues("server.port=0").run((context) -> {
|
.withPropertyValues("server.port=0").run((context) -> {
|
||||||
SessionRepositoryFilter<?> filter = context.getBean(SessionRepositoryFilter.class);
|
SessionRepositoryFilter<?> filter = context.getBean(SessionRepositoryFilter.class);
|
||||||
assertThat(filter).extracting("httpSessionIdResolver").extracting("cookieSerializer")
|
assertThat(filter).extracting("httpSessionIdResolver.cookieSerializer")
|
||||||
.isSameAs(context.getBean(DefaultCookieSerializer.class));
|
.isSameAs(context.getBean(DefaultCookieSerializer.class));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -131,7 +131,7 @@ class TransactionAutoConfigurationTests {
|
||||||
this.contextRunner.withUserConfiguration(SeveralPlatformTransactionManagersConfiguration.class)
|
this.contextRunner.withUserConfiguration(SeveralPlatformTransactionManagersConfiguration.class)
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
TransactionManagerCustomizers customizers = context.getBean(TransactionManagerCustomizers.class);
|
TransactionManagerCustomizers customizers = context.getBean(TransactionManagerCustomizers.class);
|
||||||
assertThat(customizers).extracting("customizers").asList().hasSize(1).first()
|
assertThat(customizers).extracting("customizers").asList().singleElement()
|
||||||
.isInstanceOf(TransactionProperties.class);
|
.isInstanceOf(TransactionProperties.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,8 +304,7 @@ class SpringApplicationBuilderTests {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
SpringApplication application = applicationBuilder.build();
|
SpringApplication application = applicationBuilder.build();
|
||||||
assertThat(application).isInstanceOf(CustomSpringApplication.class)
|
assertThat(application).asInstanceOf(InstanceOfAssertFactories.type(CustomSpringApplication.class))
|
||||||
.asInstanceOf(InstanceOfAssertFactories.type(CustomSpringApplication.class))
|
|
||||||
.satisfies((customApp) -> assertThat(customApp.resourceLoader).isEqualTo(resourceLoader));
|
.satisfies((customApp) -> assertThat(customApp.resourceLoader).isEqualTo(resourceLoader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
|
||||||
void defaultTomcatListeners() {
|
void defaultTomcatListeners() {
|
||||||
TomcatReactiveWebServerFactory factory = getFactory();
|
TomcatReactiveWebServerFactory factory = getFactory();
|
||||||
if (AprLifecycleListener.isAprAvailable()) {
|
if (AprLifecycleListener.isAprAvailable()) {
|
||||||
assertThat(factory.getContextLifecycleListeners()).hasSize(1).first()
|
assertThat(factory.getContextLifecycleListeners()).singleElement().isInstanceOf(AprLifecycleListener.class);
|
||||||
.isInstanceOf(AprLifecycleListener.class);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assertThat(factory.getContextLifecycleListeners()).isEmpty();
|
assertThat(factory.getContextLifecycleListeners()).isEmpty();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -135,8 +135,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
|
||||||
void defaultTomcatListeners() {
|
void defaultTomcatListeners() {
|
||||||
TomcatServletWebServerFactory factory = getFactory();
|
TomcatServletWebServerFactory factory = getFactory();
|
||||||
if (AprLifecycleListener.isAprAvailable()) {
|
if (AprLifecycleListener.isAprAvailable()) {
|
||||||
assertThat(factory.getContextLifecycleListeners()).hasSize(1).first()
|
assertThat(factory.getContextLifecycleListeners()).singleElement().isInstanceOf(AprLifecycleListener.class);
|
||||||
.isInstanceOf(AprLifecycleListener.class);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assertThat(factory.getContextLifecycleListeners()).isEmpty();
|
assertThat(factory.getContextLifecycleListeners()).isEmpty();
|
||||||
|
|
Loading…
Reference in New Issue