Refactor AssertJ assertions into more idiomatic ones
This commit refactors some AssertJ assertions into more idiomatic and readable ones. Using the dedicated assertion instead of a generic one will produce more meaningful error messages. For instance, consider collection size: ``` // expected: 5 but was: 2 assertThat(collection.size()).equals(5); // Expected size: 5 but was: 2 in: [1, 2] assertThat(collection).hasSize(5); ``` Closes gh-30104
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -130,7 +130,7 @@ public class GsonMessageConverterTests {
|
||||
MethodParameter param = new MethodParameter(method, 0);
|
||||
Object actual = converter.fromMessage(message, MyBean.class, param);
|
||||
|
||||
assertThat(actual instanceof MyBean).isTrue();
|
||||
assertThat(actual).isInstanceOf(MyBean.class);
|
||||
assertThat(((MyBean) actual).getString()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ public class GsonMessageConverterTests {
|
||||
Message<?> message = converter.toMessage(payload, null);
|
||||
String actual = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(actual.contains("\"string\":\"Foo\"")).isTrue();
|
||||
assertThat(actual.contains("\"number\":42")).isTrue();
|
||||
assertThat(actual.contains("fraction\":42.0")).isTrue();
|
||||
assertThat(actual.contains("\"array\":[\"Foo\",\"Bar\"]")).isTrue();
|
||||
assertThat(actual.contains("\"bool\":true")).isTrue();
|
||||
assertThat(actual).contains("\"string\":\"Foo\"");
|
||||
assertThat(actual).contains("\"number\":42");
|
||||
assertThat(actual).contains("fraction\":42.0");
|
||||
assertThat(actual).contains("\"array\":[\"Foo\",\"Bar\"]");
|
||||
assertThat(actual).contains("\"bool\":true");
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class)).as("Invalid content-type").isEqualTo(new MimeType("application", "json"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -131,7 +131,7 @@ public class JsonbMessageConverterTests {
|
||||
MethodParameter param = new MethodParameter(method, 0);
|
||||
Object actual = converter.fromMessage(message, MyBean.class, param);
|
||||
|
||||
assertThat(actual instanceof MyBean).isTrue();
|
||||
assertThat(actual).isInstanceOf(MyBean.class);
|
||||
assertThat(((MyBean) actual).getString()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@@ -148,11 +148,11 @@ public class JsonbMessageConverterTests {
|
||||
Message<?> message = converter.toMessage(payload, null);
|
||||
String actual = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(actual.contains("\"string\":\"Foo\"")).isTrue();
|
||||
assertThat(actual.contains("\"number\":42")).isTrue();
|
||||
assertThat(actual.contains("fraction\":42.0")).isTrue();
|
||||
assertThat(actual.contains("\"array\":[\"Foo\",\"Bar\"]")).isTrue();
|
||||
assertThat(actual.contains("\"bool\":true")).isTrue();
|
||||
assertThat(actual).contains("\"string\":\"Foo\"");
|
||||
assertThat(actual).contains("\"number\":42");
|
||||
assertThat(actual).contains("fraction\":42.0");
|
||||
assertThat(actual).contains("\"array\":[\"Foo\",\"Bar\"]");
|
||||
assertThat(actual).contains("\"bool\":true");
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class)).as("Invalid content-type").isEqualTo(new MimeType("application", "json"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -155,7 +155,7 @@ public class MappingJackson2MessageConverterTests {
|
||||
MethodParameter param = new MethodParameter(method, 0);
|
||||
Object actual = converter.fromMessage(message, MyBean.class, param);
|
||||
|
||||
assertThat(actual instanceof MyBean).isTrue();
|
||||
assertThat(actual).isInstanceOf(MyBean.class);
|
||||
assertThat(((MyBean) actual).getString()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@@ -173,12 +173,12 @@ public class MappingJackson2MessageConverterTests {
|
||||
Message<?> message = converter.toMessage(payload, null);
|
||||
String actual = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(actual.contains("\"string\":\"Foo\"")).isTrue();
|
||||
assertThat(actual.contains("\"number\":42")).isTrue();
|
||||
assertThat(actual.contains("fraction\":42.0")).isTrue();
|
||||
assertThat(actual.contains("\"array\":[\"Foo\",\"Bar\"]")).isTrue();
|
||||
assertThat(actual.contains("\"bool\":true")).isTrue();
|
||||
assertThat(actual.contains("\"bytes\":\"AQI=\"")).isTrue();
|
||||
assertThat(actual).contains("\"string\":\"Foo\"");
|
||||
assertThat(actual).contains("\"number\":42");
|
||||
assertThat(actual).contains("fraction\":42.0");
|
||||
assertThat(actual).contains("\"array\":[\"Foo\",\"Bar\"]");
|
||||
assertThat(actual).contains("\"bool\":true");
|
||||
assertThat(actual).contains("\"bytes\":\"AQI=\"");
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class)).as("Invalid content-type").isEqualTo(new MimeType("application", "json"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -116,7 +116,7 @@ public class MessageReceivingTemplateTests {
|
||||
this.template.receiveAndConvert(Writer.class);
|
||||
}
|
||||
catch (MessageConversionException ex) {
|
||||
assertThat(ex.getMessage().contains("payload")).as("Invalid exception message '" + ex.getMessage() + "'").isTrue();
|
||||
assertThat(ex.getMessage()).as("Invalid exception message '" + ex.getMessage() + "'").contains("payload");
|
||||
assertThat(ex.getFailedMessage()).isSameAs(expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -108,7 +108,7 @@ public class MessageSendingTemplateTests {
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("home");
|
||||
assertThat(this.template.message).isNotNull();
|
||||
assertThat(this.template.message.getHeaders().size()).as("expected 'id' and 'timestamp' headers only").isEqualTo(2);
|
||||
assertThat(this.template.message.getHeaders()).as("expected 'id' and 'timestamp' headers only").hasSize(2);
|
||||
assertThat(this.template.message.getPayload()).isEqualTo("payload");
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class MessageSendingTemplateTests {
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
assertThat(this.template.message).isNotNull();
|
||||
assertThat(this.template.message.getHeaders().size()).as("expected 'id' and 'timestamp' headers only").isEqualTo(2);
|
||||
assertThat(this.template.message.getHeaders()).as("expected 'id' and 'timestamp' headers only").hasSize(2);
|
||||
assertThat(this.template.message.getPayload()).isEqualTo("payload");
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MessageSendingTemplateTests {
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("home");
|
||||
assertThat(this.template.message).isNotNull();
|
||||
assertThat(this.template.message.getHeaders().size()).as("expected 'id' and 'timestamp' headers only").isEqualTo(2);
|
||||
assertThat(this.template.message.getHeaders()).as("expected 'id' and 'timestamp' headers only").hasSize(2);
|
||||
assertThat(this.template.message.getPayload()).isEqualTo("payload");
|
||||
|
||||
assertThat(this.postProcessor.getMessage()).isNotNull();
|
||||
@@ -168,7 +168,7 @@ public class MessageSendingTemplateTests {
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
assertThat(this.template.message).isNotNull();
|
||||
assertThat(this.template.message.getHeaders().size()).as("expected 'id' and 'timestamp' headers only").isEqualTo(2);
|
||||
assertThat(this.template.message.getHeaders()).as("expected 'id' and 'timestamp' headers only").hasSize(2);
|
||||
assertThat(this.template.message.getPayload()).isEqualTo("payload");
|
||||
|
||||
assertThat(this.postProcessor.getMessage()).isNotNull();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -50,7 +50,7 @@ public class DestinationPatternsMessageConditionTests {
|
||||
@Test
|
||||
public void prependNonEmptyPatternsOnly() {
|
||||
DestinationPatternsMessageCondition c = condition("");
|
||||
assertThat(c.getPatterns().iterator().next()).isEqualTo("");
|
||||
assertThat(c.getPatterns().iterator().next()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -87,7 +87,7 @@ public class PayloadMethodArgumentResolverTests {
|
||||
StepVerifier.create(mono)
|
||||
.consumeErrorWith(ex -> {
|
||||
assertThat(ex.getClass()).isEqualTo(MethodArgumentResolutionException.class);
|
||||
assertThat(ex.getMessage().contains("Payload content is missing")).as(ex.getMessage()).isTrue();
|
||||
assertThat(ex.getMessage()).as(ex.getMessage()).contains("Payload content is missing");
|
||||
})
|
||||
.verify();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -121,7 +121,7 @@ public class DefaultRSocketRequesterTests {
|
||||
if (Arrays.equals(new String[] {""}, expectedValues)) {
|
||||
assertThat(payloads).hasSize(1);
|
||||
assertThat(payloads.get(0).getMetadataUtf8()).isEqualTo("toA");
|
||||
assertThat(payloads.get(0).getDataUtf8()).isEqualTo("");
|
||||
assertThat(payloads.get(0).getDataUtf8()).isEmpty();
|
||||
}
|
||||
else {
|
||||
assertThat(payloads.stream().map(Payload::getMetadataUtf8).toArray(String[]::new))
|
||||
@@ -137,7 +137,7 @@ public class DefaultRSocketRequesterTests {
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("fireAndForget");
|
||||
assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo("");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,7 +197,7 @@ public class DefaultRSocketRequesterTests {
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse");
|
||||
assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo("");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -228,7 +228,7 @@ public class DefaultRSocketRequesterTests {
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestStream");
|
||||
assertThat(this.rsocket.getSavedPayload().getMetadataUtf8()).isEqualTo("toA");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEqualTo("");
|
||||
assertThat(this.rsocket.getSavedPayload().getDataUtf8()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -258,7 +258,7 @@ class RSocketBufferLeakTests {
|
||||
while (true) {
|
||||
try {
|
||||
int count = info.getReferenceCount();
|
||||
assertThat(count == 0).as("Leaked payload (refCnt=" + count + "): " + info).isTrue();
|
||||
assertThat(count).as("Leaked payload (refCnt=" + count + "): " + info).isEqualTo(0);
|
||||
break;
|
||||
}
|
||||
catch (AssertionError ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -175,7 +175,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
||||
assertThat(this.testController.method).isEqualTo("simpleBinding");
|
||||
assertThat(this.testController.arguments.get("id") instanceof Long).as("should be bound to type long").isTrue();
|
||||
assertThat(this.testController.arguments.get("id")).as("should be bound to type long").isInstanceOf(Long.class);
|
||||
assertThat(this.testController.arguments.get("id")).isEqualTo(12L);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -76,7 +76,7 @@ public class DefaultSubscriptionRegistryTests {
|
||||
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected one element " + actual).isEqualTo(1);
|
||||
assertThat(actual).as("Expected one element " + actual).hasSize(1);
|
||||
assertThat(actual.get(sessId)).isEqualTo(Collections.singletonList(subsId));
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class DefaultSubscriptionRegistryTests {
|
||||
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected one element " + actual).isEqualTo(1);
|
||||
assertThat(actual).as("Expected one element " + actual).hasSize(1);
|
||||
assertThat(actual.get(sessId)).isEqualTo(Collections.singletonList(subsId));
|
||||
}
|
||||
|
||||
@@ -256,19 +256,19 @@ public class DefaultSubscriptionRegistryTests {
|
||||
Message<?> message = createMessage("/topic/PRICE.STOCK.NASDAQ.IBM");
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(message);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected one element " + actual).isEqualTo(1);
|
||||
assertThat(actual).as("Expected one element " + actual).hasSize(1);
|
||||
assertThat(actual.get(sessId)).isEqualTo(Collections.singletonList(subsId));
|
||||
|
||||
message = createMessage("/topic/PRICE.STOCK.NASDAQ.MSFT");
|
||||
actual = this.registry.findSubscriptions(message);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected one element " + actual).isEqualTo(1);
|
||||
assertThat(actual).as("Expected one element " + actual).hasSize(1);
|
||||
assertThat(actual.get(sessId)).isEqualTo(Collections.singletonList(subsId));
|
||||
|
||||
message = createMessage("/topic/PRICE.STOCK.NASDAQ.VMW");
|
||||
actual = this.registry.findSubscriptions(message);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected no elements " + actual).isEqualTo(0);
|
||||
assertThat(actual).as("Expected no elements " + actual).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,21 +327,21 @@ public class DefaultSubscriptionRegistryTests {
|
||||
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage("/foo"));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected 1 element").isEqualTo(1);
|
||||
assertThat(actual).as("Expected 1 element").hasSize(1);
|
||||
assertThat(actual.get("sess01")).isEqualTo(Arrays.asList("subs01", "subs02"));
|
||||
|
||||
this.registry.unregisterSubscription(unsubscribeMessage("sess01", "subs01"));
|
||||
|
||||
actual = this.registry.findSubscriptions(createMessage("/foo"));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected 1 element").isEqualTo(1);
|
||||
assertThat(actual).as("Expected 1 element").hasSize(1);
|
||||
assertThat(actual.get("sess01")).isEqualTo(Collections.singletonList("subs02"));
|
||||
|
||||
this.registry.unregisterSubscription(unsubscribeMessage("sess01", "subs02"));
|
||||
|
||||
actual = this.registry.findSubscriptions(createMessage("/foo"));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected no element").isEqualTo(0);
|
||||
assertThat(actual).as("Expected no element").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -362,7 +362,7 @@ public class DefaultSubscriptionRegistryTests {
|
||||
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected two elements: " + actual).isEqualTo(2);
|
||||
assertThat(actual).as("Expected two elements: " + actual).hasSize(2);
|
||||
assertThat(sort(actual.get(sessIds.get(1)))).isEqualTo(subscriptionIds);
|
||||
assertThat(sort(actual.get(sessIds.get(2)))).isEqualTo(subscriptionIds);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ public class DefaultSubscriptionRegistryTests {
|
||||
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected one element: " + actual).isEqualTo(1);
|
||||
assertThat(actual).as("Expected one element: " + actual).hasSize(1);
|
||||
assertThat(sort(actual.get(sessIds.get(2)))).isEqualTo(subscriptionIds);
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public class DefaultSubscriptionRegistryTests {
|
||||
public void findSubscriptionsNoMatches() {
|
||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage("/foo"));
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.size()).as("Expected no elements " + actual).isEqualTo(0);
|
||||
assertThat(actual).as("Expected no elements " + actual).isEmpty();
|
||||
}
|
||||
|
||||
@Test // SPR-12665
|
||||
|
||||
@@ -442,7 +442,7 @@ public class MessageBrokerConfigurationTests {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
SimpUserRegistry registry = context.getBean(SimpUserRegistry.class);
|
||||
assertThat(registry instanceof TestUserRegistry).isTrue();
|
||||
assertThat(registry).isInstanceOf(TestUserRegistry.class);
|
||||
assertThat(((TestUserRegistry) registry).getOrder()).isEqualTo(99);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -146,7 +146,7 @@ public class BufferingStompDecoderTests {
|
||||
String chunk1 = "SEND\na:alpha\n\nPayload1\0SEND\ncontent-length:129\n";
|
||||
List<Message<byte[]>> messages = stompDecoder.decode(toByteBuffer(chunk1));
|
||||
|
||||
assertThat(messages.size()).as("We should have gotten the 1st message").isEqualTo(1);
|
||||
assertThat(messages).as("We should have gotten the 1st message").hasSize(1);
|
||||
assertThat(new String(messages.get(0).getPayload())).isEqualTo("Payload1");
|
||||
|
||||
assertThat(stompDecoder.getBufferSize()).isEqualTo(24);
|
||||
|
||||
@@ -363,7 +363,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.SEND);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(2);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(2);
|
||||
|
||||
assertThat(stompHeaders.getDestination()).isEqualTo(destination);
|
||||
assertThat(stompHeaders.getContentType()).isEqualTo(new MimeType("text", "plain", StandardCharsets.UTF_8));
|
||||
@@ -408,7 +408,7 @@ public class DefaultStompSessionTests {
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(2);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(2);
|
||||
|
||||
assertThat(stompHeaders.getDestination()).isEqualTo(destination);
|
||||
assertThat(stompHeaders.getContentType()).isEqualTo(MimeTypeUtils.APPLICATION_OCTET_STREAM);
|
||||
@@ -457,7 +457,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.SUBSCRIBE);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(2);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(2);
|
||||
assertThat(stompHeaders.getDestination()).isEqualTo(destination);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(subscription.getSubscriptionId());
|
||||
}
|
||||
@@ -483,7 +483,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.SUBSCRIBE);
|
||||
|
||||
stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(2);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(2);
|
||||
assertThat(stompHeaders.getDestination()).isEqualTo(destination);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(subscriptionId);
|
||||
}
|
||||
@@ -503,7 +503,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.UNSUBSCRIBE);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(1);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(1);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(subscription.getSubscriptionId());
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.UNSUBSCRIBE);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(2);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(2);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(subscription.getSubscriptionId());
|
||||
assertThat(stompHeaders.getFirst(headerName)).isEqualTo(headerValue);
|
||||
}
|
||||
@@ -548,7 +548,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.ACK);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(1);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(1);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(messageId);
|
||||
}
|
||||
|
||||
@@ -565,7 +565,7 @@ public class DefaultStompSessionTests {
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.NACK);
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(stompHeaders.size()).as(stompHeaders.toString()).isEqualTo(1);
|
||||
assertThat(stompHeaders).as(stompHeaders.toString()).hasSize(1);
|
||||
assertThat(stompHeaders.getId()).isEqualTo(messageId);
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ public class DefaultStompSessionTests {
|
||||
Message<byte[]> message = this.messageCaptor.getValue();
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
headers = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(headers.size()).as(headers.toString()).isEqualTo(1);
|
||||
assertThat(headers).as(headers.toString()).hasSize(1);
|
||||
assertThat(headers.get("foo")).hasSize(1);
|
||||
assertThat(headers.get("foo").get(0)).isEqualTo("bar");
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ class StompBrokerRelayMessageHandlerTests {
|
||||
}
|
||||
|
||||
public StompHeaderAccessor getSentHeaders(int index) {
|
||||
assertThat(getSentMessages().size() > index).as("Size: " + getSentMessages().size()).isTrue();
|
||||
assertThat(getSentMessages().size()).as("Size: " + getSentMessages().size()).isGreaterThan(index);
|
||||
Message<byte[]> message = getSentMessages().get(index);
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
assertThat(accessor).isNotNull();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -131,7 +131,7 @@ public class StompDecoderTests {
|
||||
assertThat(headers.getContentLength()).isEqualTo(Integer.valueOf(0));
|
||||
|
||||
String bodyText = new String(frame.getPayload());
|
||||
assertThat(bodyText).isEqualTo("");
|
||||
assertThat(bodyText).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,7 +218,7 @@ public class StompDecoderTests {
|
||||
|
||||
assertThat(headers.toNativeHeaderMap()).hasSize(2);
|
||||
assertThat(headers.getFirstNativeHeader("accept-version")).isEqualTo("1.1");
|
||||
assertThat(headers.getFirstNativeHeader("key")).isEqualTo("");
|
||||
assertThat(headers.getFirstNativeHeader("key")).isEmpty();
|
||||
|
||||
assertThat(frame.getPayload()).isEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user