Use idiomatic AssertJ assertions for true, false, and null

This commit is contained in:
Sam Brannen
2022-01-10 14:15:55 +01:00
parent 2a80b64d40
commit df263d01b9
75 changed files with 345 additions and 333 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -189,7 +189,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
simpleFactory.getListenerContainer("first").getEndpoint();
assertThat(first.getId()).isEqualTo("first");
assertThat(first.getDestination()).isEqualTo("myQueue");
assertThat(first.getConcurrency()).isEqualTo(null);
assertThat(first.getConcurrency()).isNull();
MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint)
simpleFactory.getListenerContainer("second").getEndpoint();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -179,14 +179,14 @@ public class JmsListenerContainerFactoryTests {
assertThat(container.getConnectionFactory()).isEqualTo(this.connectionFactory);
assertThat(container.getDestinationResolver()).isEqualTo(this.destinationResolver);
assertThat(container.getMessageConverter()).isEqualTo(this.messageConverter);
assertThat(container.isSessionTransacted()).isEqualTo(true);
assertThat(container.isSessionTransacted()).isTrue();
assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
assertThat(container.isPubSubDomain()).isEqualTo(true);
assertThat(container.isReplyPubSubDomain()).isEqualTo(true);
assertThat(container.isPubSubDomain()).isTrue();
assertThat(container.isReplyPubSubDomain()).isTrue();
assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
assertThat(container.isSubscriptionDurable()).isEqualTo(true);
assertThat(container.isSubscriptionDurable()).isTrue();
assertThat(container.getClientId()).isEqualTo("client-1234");
assertThat(container.isAutoStartup()).isEqualTo(false);
assertThat(container.isAutoStartup()).isFalse();
}
private void setDefaultJcaConfig(DefaultJcaListenerContainerFactory factory) {
@@ -206,9 +206,9 @@ public class JmsListenerContainerFactoryTests {
JmsActivationSpecConfig config = container.getActivationSpecConfig();
assertThat(config).isNotNull();
assertThat(config.getAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
assertThat(config.isPubSubDomain()).isEqualTo(true);
assertThat(config.isPubSubDomain()).isTrue();
assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
assertThat(config.isSubscriptionDurable()).isEqualTo(true);
assertThat(config.isSubscriptionDurable()).isTrue();
assertThat(config.getClientId()).isEqualTo("client-1234");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -145,8 +145,8 @@ public class JmsNamespaceHandlerTests {
assertThat(container.getConnectionFactory()).as("explicit connection factory not set").isEqualTo(context.getBean(EXPLICIT_CONNECTION_FACTORY));
assertThat(container.getDestinationResolver()).as("explicit destination resolver not set").isEqualTo(context.getBean("testDestinationResolver"));
assertThat(container.getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter"));
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true);
assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isEqualTo(true);
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue();
assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isTrue();
assertThat(container.getCacheLevel()).as("wrong cache").isEqualTo(DefaultMessageListenerContainer.CACHE_CONNECTION);
assertThat(container.getConcurrentConsumers()).as("wrong concurrency").isEqualTo(3);
assertThat(container.getMaxConcurrentConsumers()).as("wrong concurrency").isEqualTo(5);
@@ -166,7 +166,7 @@ public class JmsNamespaceHandlerTests {
factory.createListenerContainer(createDummyEndpoint());
assertThat(container.getResourceAdapter()).as("explicit resource adapter not set").isEqualTo(context.getBean("testResourceAdapter"));
assertThat(container.getActivationSpecConfig().getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter"));
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true);
assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue();
assertThat(container.getActivationSpecConfig().getMaxConcurrency()).as("wrong concurrency").isEqualTo(5);
assertThat(container.getActivationSpecConfig().getPrefetchSize()).as("Wrong prefetch").isEqualTo(50);
assertThat(container.getPhase()).as("Wrong phase").isEqualTo(77);
@@ -248,20 +248,20 @@ public class JmsNamespaceHandlerTests {
.getBean("listener1", DefaultMessageListenerContainer.class);
DefaultMessageListenerContainer listener2 = this.context
.getBean("listener2", DefaultMessageListenerContainer.class);
assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isEqualTo(true);
assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isEqualTo(true);
assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isEqualTo(false);
assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isEqualTo(false);
assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isTrue();
assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isTrue();
assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isFalse();
assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isFalse();
// JCA
JmsMessageEndpointManager listener3 = this.context
.getBean("listener3", JmsMessageEndpointManager.class);
JmsMessageEndpointManager listener4 = this.context
.getBean("listener4", JmsMessageEndpointManager.class);
assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isEqualTo(true);
assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isEqualTo(true);
assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isEqualTo(false);
assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isEqualTo(false);
assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isTrue();
assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isTrue();
assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isFalse();
assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -65,6 +65,7 @@ import org.springframework.validation.annotation.Validated;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -570,7 +571,7 @@ class MethodJmsListenerEndpointTests {
this.invocations.put("resolveJmsMessageHeaderAccessor", true);
assertThat(headers).as("MessageHeaders not injected").isNotNull();
assertThat(headers.getPriority()).as("Missing JMS message priority header").isEqualTo(Integer.valueOf(9));
assertThat(headers.getHeader("customBoolean")).as("Missing custom header").isEqualTo(true);
assertThat(headers.getHeader("customBoolean")).as("Missing custom header").asInstanceOf(BOOLEAN).isTrue();
}
public void resolveObjectPayload(MyBean bean) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -52,11 +52,11 @@ public class DefaultMessageListenerContainerTests {
DefaultMessageListenerContainer container = createContainer(createFailingContainerFactory());
container.setBackOff(backOff);
container.start();
assertThat(container.isRunning()).isEqualTo(true);
assertThat(container.isRunning()).isTrue();
container.refreshConnectionUntilSuccessful();
assertThat(container.isRunning()).isEqualTo(false);
assertThat(container.isRunning()).isFalse();
verify(backOff).start();
verify(execution).nextBackOff();
}
@@ -73,7 +73,7 @@ public class DefaultMessageListenerContainerTests {
container.start();
container.refreshConnectionUntilSuccessful();
assertThat(container.isRunning()).isEqualTo(false);
assertThat(container.isRunning()).isFalse();
verify(backOff).start();
verify(execution, times(2)).nextBackOff();
}
@@ -90,7 +90,7 @@ public class DefaultMessageListenerContainerTests {
container.start();
container.refreshConnectionUntilSuccessful();
assertThat(container.isRunning()).isEqualTo(true);
assertThat(container.isRunning()).isTrue();
verify(backOff).start();
verify(execution, times(1)).nextBackOff(); // only on attempt as the second one lead to a recovery
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -34,8 +34,8 @@ public class JmsMessageEndpointManagerTests {
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(false);
endpoint.setActivationSpecConfig(config);
assertThat(endpoint.isPubSubDomain()).isEqualTo(false);
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false);
assertThat(endpoint.isPubSubDomain()).isFalse();
assertThat(endpoint.isReplyPubSubDomain()).isFalse();
}
@Test
@@ -44,8 +44,8 @@ public class JmsMessageEndpointManagerTests {
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(true);
endpoint.setActivationSpecConfig(config);
assertThat(endpoint.isPubSubDomain()).isEqualTo(true);
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(true);
assertThat(endpoint.isPubSubDomain()).isTrue();
assertThat(endpoint.isReplyPubSubDomain()).isTrue();
}
@Test
@@ -55,8 +55,8 @@ public class JmsMessageEndpointManagerTests {
config.setPubSubDomain(true);
config.setReplyPubSubDomain(false);
endpoint.setActivationSpecConfig(config);
assertThat(endpoint.isPubSubDomain()).isEqualTo(true);
assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false);
assertThat(endpoint.isPubSubDomain()).isTrue();
assertThat(endpoint.isReplyPubSubDomain()).isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -65,7 +65,7 @@ public class JmsMessageHeaderAccessorTests {
assertThat(headerAccessor.getMessageId()).isEqualTo("abcd-1234");
assertThat(headerAccessor.getPriority()).isEqualTo(Integer.valueOf(9));
assertThat(headerAccessor.getReplyTo()).isEqualTo(replyTo);
assertThat(headerAccessor.getRedelivered()).isEqualTo(true);
assertThat(headerAccessor.getRedelivered()).isTrue();
assertThat(headerAccessor.getType()).isEqualTo("type");
assertThat(headerAccessor.getTimestamp()).isEqualTo(4567);