org.springframework.integration.test.matcher
Class MockitoMessageMatchers
java.lang.Object
org.springframework.integration.test.matcher.MockitoMessageMatchers
public class MockitoMessageMatchers
- extends java.lang.Object
Mockito matcher factory for 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));
- Author:
- Alex Peters, Iwein Fuld
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MockitoMessageMatchers
public MockitoMessageMatchers()
messageWithPayload
public static <T> Message<T> messageWithPayload(org.hamcrest.Matcher<T> payloadMatcher)
messageWithPayload
public static <T> Message<T> messageWithPayload(T payload)
messageWithHeaderEntry
public static Message<?> messageWithHeaderEntry(java.lang.String key,
java.lang.Object value)
messageWithHeaderKey
public static Message<?> messageWithHeaderKey(java.lang.String key)
messageWithHeaderEntry
public static <T> Message<?> messageWithHeaderEntry(java.lang.String key,
org.hamcrest.Matcher<T> valueMatcher)
messageWithHeaderEntries
public static Message<?> messageWithHeaderEntries(java.util.Map<java.lang.String,?> entries)