public class PayloadMatcher
extends org.hamcrest.BaseMatcher<T>
Message equal to a given value or is matching
a given matcher?
A Junit example using Assert.assertThat(Object, Matcher) could look
like this to test a payload value:
ANY_PAYLOAD = new BigDecimal("1.123");
Message<BigDecimal message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
assertThat(message, hasPayload(ANY_PAYLOjAD));
An example using Assert.assertThat(Object, Matcher) delegating to
another Matcher.
ANY_PAYLOAD = new BigDecimal("1.123");
assertThat(message, PayloadMatcher.hasPayload(is(BigDecimal.class)));
assertThat(message, PayloadMatcher.hasPayload(notNullValue()));
assertThat(message, not((PayloadMatcher.hasPayload(is(String.class))))); *
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description) |
static <T> org.hamcrest.Matcher<org.springframework.messaging.Message> |
hasPayload(org.hamcrest.Matcher<? super T> payloadMatcher) |
static <T> org.hamcrest.Matcher<org.springframework.messaging.Message> |
hasPayload(T payload) |
boolean |
matches(java.lang.Object item)
Method made final to prevent accidental override.
|
boolean |
matchesSafely(org.springframework.messaging.Message message)
Subclasses should implement this.
|
public boolean matchesSafely(org.springframework.messaging.Message message)
public void describeTo(org.hamcrest.Description description)
public static <T> org.hamcrest.Matcher<org.springframework.messaging.Message> hasPayload(T payload)
public static <T> org.hamcrest.Matcher<org.springframework.messaging.Message> hasPayload(org.hamcrest.Matcher<? super T> payloadMatcher)
public final boolean matches(java.lang.Object item)
BaseMatcher.