Use hasSize() assertion in favor of length checks
See gh-17874
This commit is contained in:
committed by
Stephane Nicoll
parent
04b63cda8f
commit
d4affd7f85
@@ -471,7 +471,7 @@ class RabbitAutoConfigurationTests {
|
||||
RetryPolicy retryPolicy) {
|
||||
Advice[] adviceChain = rabbitListenerContainerFactory.getAdviceChain();
|
||||
assertThat(adviceChain).isNotNull();
|
||||
assertThat(adviceChain.length).isEqualTo(1);
|
||||
assertThat(adviceChain).hasSize(1);
|
||||
Advice advice = adviceChain[0];
|
||||
RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(advice, "retryOperations");
|
||||
assertThat(retryTemplate).hasFieldOrPropertyWithValue("retryPolicy", retryPolicy);
|
||||
@@ -533,7 +533,7 @@ class RabbitAutoConfigurationTests {
|
||||
assertThat(containerFactory).hasFieldOrPropertyWithValue("idleEventInterval", 5L);
|
||||
Advice[] adviceChain = containerFactory.getAdviceChain();
|
||||
assertThat(adviceChain).isNotNull();
|
||||
assertThat(adviceChain.length).isEqualTo(1);
|
||||
assertThat(adviceChain).hasSize(1);
|
||||
Advice advice = adviceChain[0];
|
||||
MessageRecoverer messageRecoverer = context.getBean("myMessageRecoverer", MessageRecoverer.class);
|
||||
MethodInvocationRecoverer<?> mir = (MethodInvocationRecoverer<?>) ReflectionTestUtils.getField(advice,
|
||||
|
||||
@@ -64,7 +64,7 @@ class CassandraDataAutoConfigurationTests {
|
||||
@Test
|
||||
void templateExists() {
|
||||
load(TestExcludeConfiguration.class);
|
||||
assertThat(this.context.getBeanNamesForType(CassandraTemplate.class).length).isEqualTo(1);
|
||||
assertThat(this.context.getBeanNamesForType(CassandraTemplate.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -69,7 +69,7 @@ class ElasticsearchAutoConfigurationTests {
|
||||
this.context.register(CustomConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeanNamesForType(Client.class).length).isEqualTo(1);
|
||||
assertThat(this.context.getBeanNamesForType(Client.class)).hasSize(1);
|
||||
assertThat(this.context.getBean("myClient")).isSameAs(this.context.getBean(Client.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ class ArtemisAutoConfigurationTests {
|
||||
private TransportConfiguration getSingleTransportConfiguration(ActiveMQConnectionFactory connectionFactory) {
|
||||
TransportConfiguration[] transportConfigurations = connectionFactory.getServerLocator()
|
||||
.getStaticTransportConfigurations();
|
||||
assertThat(transportConfigurations.length).isEqualTo(1);
|
||||
assertThat(transportConfigurations).hasSize(1);
|
||||
return transportConfigurations[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class ArtemisEmbeddedConfigurationFactoryTests {
|
||||
void generatedClusterPassword() {
|
||||
ArtemisProperties properties = new ArtemisProperties();
|
||||
Configuration configuration = new ArtemisEmbeddedConfigurationFactory(properties).createConfiguration();
|
||||
assertThat(configuration.getClusterPassword().length()).isEqualTo(36);
|
||||
assertThat(configuration.getClusterPassword()).hasSize(36);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -122,13 +122,13 @@ class JooqAutoConfigurationTests {
|
||||
assertThat(dsl.configuration().recordUnmapperProvider().getClass())
|
||||
.isEqualTo(TestRecordUnmapperProvider.class);
|
||||
assertThat(dsl.configuration().executorProvider().getClass()).isEqualTo(TestExecutorProvider.class);
|
||||
assertThat(dsl.configuration().recordListenerProviders().length).isEqualTo(1);
|
||||
assertThat(dsl.configuration().recordListenerProviders()).hasSize(1);
|
||||
ExecuteListenerProvider[] executeListenerProviders = dsl.configuration().executeListenerProviders();
|
||||
assertThat(executeListenerProviders.length).isEqualTo(2);
|
||||
assertThat(executeListenerProviders).hasSize(2);
|
||||
assertThat(executeListenerProviders[0]).isInstanceOf(DefaultExecuteListenerProvider.class);
|
||||
assertThat(executeListenerProviders[1]).isInstanceOf(TestExecuteListenerProvider.class);
|
||||
assertThat(dsl.configuration().visitListenerProviders().length).isEqualTo(1);
|
||||
assertThat(dsl.configuration().transactionListenerProviders().length).isEqualTo(1);
|
||||
assertThat(dsl.configuration().visitListenerProviders()).hasSize(1);
|
||||
assertThat(dsl.configuration().transactionListenerProviders()).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class EmbeddedLdapAutoConfigurationTests {
|
||||
void testQueryEmbeddedLdap() {
|
||||
this.contextRunner.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
|
||||
.withConfiguration(AutoConfigurations.of(LdapAutoConfiguration.class)).run((context) -> {
|
||||
assertThat(context.getBeanNamesForType(LdapTemplate.class).length).isEqualTo(1);
|
||||
assertThat(context).hasSingleBean(LdapTemplate.class);
|
||||
LdapTemplate ldapTemplate = context.getBean(LdapTemplate.class);
|
||||
assertThat(ldapTemplate.list("ou=company1,c=Sweden,dc=spring,dc=org")).hasSize(4);
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ class JettyWebServerFactoryCustomizerTests {
|
||||
JettyWebServer server = customizeAndGetServer();
|
||||
CustomRequestLog requestLog = getRequestLog(server);
|
||||
assertThat(requestLog.getFormatString()).isEqualTo(CustomRequestLog.EXTENDED_NCSA_FORMAT);
|
||||
assertThat(requestLog.getIgnorePaths().length).isEqualTo(2);
|
||||
assertThat(requestLog.getIgnorePaths()).hasSize(2);
|
||||
assertThat(requestLog.getIgnorePaths()).containsExactly("/a/path", "/b/path");
|
||||
RequestLogWriter logWriter = getLogWriter(requestLog);
|
||||
assertThat(logWriter.getFileName()).isEqualTo(logFile.getAbsolutePath());
|
||||
|
||||
Reference in New Issue
Block a user