Class MockitoMessageMatchers

java.lang.Object
org.springframework.integration.test.matcher.MockitoMessageMatchers

public final class MockitoMessageMatchers
extends Object
Mockito matcher factory for Message matcher creation.

This class contains expressive factory methods for the most common Mockito matchers needed when matching Messages. If you need a different matching strategy, any Hamcrest matcher can be used in Mockito through ArgumentMatchers.argThat(org.mockito.ArgumentMatcher). 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, Artem Bilan