public final class PayloadMatcher<T> extends org.hamcrest.TypeSafeMatcher<Message<?>>
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_PAYLOAD));
An example using Assert.assertThat(Object, Matcher)
delegating to
another Matcher
.
ANY_PAYLOAD = new BigDecimal("1.123");
Message<BigDecimal> message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
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 <P> PayloadMatcher<P> |
hasPayload(org.hamcrest.Matcher<P> payloadMatcher) |
static <P> PayloadMatcher<P> |
hasPayload(P payload) |
boolean |
matchesSafely(Message<?> message) |
describeMismatch, describeMismatchSafely, matches
public boolean matchesSafely(Message<?> message)
matchesSafely
in class org.hamcrest.TypeSafeMatcher<Message<?>>
public void describeTo(org.hamcrest.Description description)
public static <P> PayloadMatcher<P> hasPayload(P payload)
public static <P> PayloadMatcher<P> hasPayload(org.hamcrest.Matcher<P> payloadMatcher)