public class MockMessageHandler extends AbstractMessageProducingHandler
AbstractMessageProducingHandler extension for the mocking purpose in tests.
The provided Consumers and Functions are applied to the incoming
messages one at a time until the last, which is applied for all subsequent messages.
The similar behavior exists in the
Mockito.doReturn(Object toBeReturned, Object... toBeReturnedNext).
Typically is used as a chain of stub actions:
MockIntegration.mockMessageHandler()
.handleNext(...)
.handleNext(...)
.handleNextAndReply(...)
.handleNextAndReply(...)
.handleNext(...)
.handleNextAndReply(...);
IntegrationManagement.ManagementOverrides| Modifier and Type | Field and Description |
|---|---|
protected boolean |
hasReplies |
protected java.util.function.Function<Message<?>,?> |
lastFunction |
protected List<java.util.function.Function<Message<?>,?>> |
messageFunctions |
messagingTemplateEXPRESSION_PARSER, loggerHIGHEST_PRECEDENCE, LOWEST_PRECEDENCEMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME| Modifier | Constructor and Description |
|---|---|
protected |
MockMessageHandler(org.mockito.ArgumentCaptor<Message<?>> messageArgumentCaptor) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
handleMessageInternal(Message<?> message) |
MockMessageHandler |
handleNext(java.util.function.Consumer<Message<?>> nextMessageConsumer)
Add the
Consumer to the stack to handle the next incoming message. |
MockMessageHandler |
handleNextAndReply(java.util.function.Function<Message<?>,?> nextMessageFunction)
Add the
Function to the stack to handle the next incoming message
and produce reply for it. |
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, onInit, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadershandleMessage, onComplete, onError, onNext, onSubscribebuildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetThisAsgetBeanName, getComponentNameprotected final List<java.util.function.Function<Message<?>,?>> messageFunctions
protected java.util.function.Function<Message<?>,?> lastFunction
protected boolean hasReplies
protected MockMessageHandler(org.mockito.ArgumentCaptor<Message<?>> messageArgumentCaptor)
public MockMessageHandler handleNext(java.util.function.Consumer<Message<?>> nextMessageConsumer)
Consumer to the stack to handle the next incoming message.nextMessageConsumer - the Consumer to handle the next incoming message.public MockMessageHandler handleNextAndReply(java.util.function.Function<Message<?>,?> nextMessageFunction)
Function to the stack to handle the next incoming message
and produce reply for it.nextMessageFunction - the Function to handle the next incoming message.protected void handleMessageInternal(Message<?> message)
handleMessageInternal in class AbstractMessageHandler