Use AssertJ's hasSize() for collections and maps
Achieved via a global search-and-replace.
This commit is contained in:
@@ -84,8 +84,8 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
JmsListenerContainerTestFactory simpleFactory =
|
||||
context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(1);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
protected void testFullConfiguration(ApplicationContext context) {
|
||||
JmsListenerContainerTestFactory simpleFactory =
|
||||
context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(1);
|
||||
MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainers().get(0).getEndpoint();
|
||||
assertThat(endpoint.getId()).isEqualTo("listener1");
|
||||
@@ -121,8 +121,8 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
JmsListenerContainerTestFactory customFactory =
|
||||
context.getBean("customFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(customFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(1);
|
||||
assertThat(customFactory.getListenerContainers()).hasSize(1);
|
||||
JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
|
||||
assertThat(endpoint.getClass()).as("Wrong endpoint type").isEqualTo(SimpleJmsListenerEndpoint.class);
|
||||
assertThat(((SimpleJmsListenerEndpoint) endpoint).getMessageListener()).as("Wrong listener set in custom endpoint").isEqualTo(context.getBean("simpleMessageListener"));
|
||||
@@ -143,7 +143,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
protected void testExplicitContainerFactoryConfiguration(ApplicationContext context) {
|
||||
JmsListenerContainerTestFactory defaultFactory =
|
||||
context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
protected void testDefaultContainerFactoryConfiguration(ApplicationContext context) {
|
||||
JmsListenerContainerTestFactory defaultFactory =
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
protected void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
|
||||
JmsListenerContainerTestFactory simpleFactory =
|
||||
context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(1);
|
||||
MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainers().get(0).getEndpoint();
|
||||
|
||||
@@ -182,7 +182,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
|
||||
protected void testJmsListenerRepeatable(ApplicationContext context) {
|
||||
JmsListenerContainerTestFactory simpleFactory =
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(2);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(2);
|
||||
|
||||
MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint)
|
||||
simpleFactory.getListenerContainer("first").getEndpoint();
|
||||
|
||||
@@ -162,7 +162,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) {
|
||||
JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory",
|
||||
JmsListenerContainerTestFactory.class);
|
||||
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(2);
|
||||
assertThat(simpleFactory.getListenerContainers()).hasSize(2);
|
||||
|
||||
MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer(
|
||||
"first").getEndpoint();
|
||||
@@ -193,10 +193,10 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
|
||||
EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class);
|
||||
JmsListenerContainerTestFactory defaultFactory =
|
||||
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(0);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(0);
|
||||
|
||||
context.getBean(LazyBean.class); // trigger lazy resolution
|
||||
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(defaultFactory.getListenerContainers()).hasSize(1);
|
||||
MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
|
||||
assertThat(container.isStarted()).as("Should have been started " + container).isTrue();
|
||||
context.close(); // close and stop the listeners
|
||||
|
||||
@@ -73,7 +73,7 @@ public class JmsListenerEndpointRegistrarTests {
|
||||
this.registrar.registerEndpoint(endpoint, null);
|
||||
this.registrar.afterPropertiesSet();
|
||||
assertThat(this.registry.getListenerContainer("some id")).as("Container not created").isNotNull();
|
||||
assertThat(this.registry.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(this.registry.getListenerContainers()).hasSize(1);
|
||||
assertThat(this.registry.getListenerContainerIds().iterator().next()).isEqualTo("some id");
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class JmsListenerEndpointRegistrarTests {
|
||||
this.registrar.registerEndpoint(endpoint);
|
||||
this.registrar.afterPropertiesSet();
|
||||
assertThat(this.registry.getListenerContainer("myEndpoint")).as("Container not created").isNotNull();
|
||||
assertThat(this.registry.getListenerContainers().size()).isEqualTo(1);
|
||||
assertThat(this.registry.getListenerContainers()).hasSize(1);
|
||||
assertThat(this.registry.getListenerContainerIds().iterator().next()).isEqualTo("myEndpoint");
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ class JmsTemplateTests {
|
||||
tac.close();
|
||||
|
||||
List<TransactionSynchronization> synchs = TransactionSynchronizationManager.getSynchronizations();
|
||||
assertThat(synchs.size()).isEqualTo(1);
|
||||
assertThat(synchs).hasSize(1);
|
||||
TransactionSynchronization synch = synchs.get(0);
|
||||
synch.beforeCommit(false);
|
||||
synch.beforeCompletion();
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MessagingMessageListenerAdapterTests {
|
||||
listener.setMessageConverter(messageConverter);
|
||||
listener.onMessage(jmsMessage, session);
|
||||
verify(messageConverter, times(1)).fromMessage(jmsMessage);
|
||||
assertThat(sample.simples.size()).isEqualTo(1);
|
||||
assertThat(sample.simples).hasSize(1);
|
||||
assertThat(sample.simples.get(0).getPayload()).isEqualTo("FooBar");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user