public class MockitoMessageMatchers
extends java.lang.Object
Message
matcher creation.
This class contains expressive factory methods for the most common Mockito
matchers needed when matching Message
s. If you need a different
matching strategy, any Hamcrest matcher can be used in Mockito through
Matchers.argThat(Matcher)
.
Example usage:
With Mockito.verify(Object)
:
@Mock
MessageHandler handler;
...
handler.handleMessage(message);
verify(handler).handleMessage(messageWithPayload(SOME_PAYLOAD));
verify(handler).handleMessage(messageWithPayload(is(SOME_CLASS)));
With Mockito.when(Object)
:
...
when(channel.send(messageWithPayload(SOME_PAYLOAD))).thenReturn(true);
assertThat(channel.send(message), is(true));
Constructor and Description |
---|
MockitoMessageMatchers() |
Modifier and Type | Method and Description |
---|---|
static Message<?> |
messageWithHeaderEntries(java.util.Map<java.lang.String,?> entries) |
static <T> Message<?> |
messageWithHeaderEntry(java.lang.String key,
org.hamcrest.Matcher<T> valueMatcher) |
static Message<?> |
messageWithHeaderEntry(java.lang.String key,
java.lang.Object value) |
static Message<?> |
messageWithHeaderKey(java.lang.String key) |
static <T> Message<T> |
messageWithPayload(org.hamcrest.Matcher<T> payloadMatcher) |
static <T> Message<T> |
messageWithPayload(T payload) |
public static <T> Message<T> messageWithPayload(org.hamcrest.Matcher<T> payloadMatcher)
public static <T> Message<T> messageWithPayload(T payload)
public static Message<?> messageWithHeaderEntry(java.lang.String key, java.lang.Object value)
public static Message<?> messageWithHeaderKey(java.lang.String key)
public static <T> Message<?> messageWithHeaderEntry(java.lang.String key, org.hamcrest.Matcher<T> valueMatcher)
public static Message<?> messageWithHeaderEntries(java.util.Map<java.lang.String,?> entries)