public class MockMessageHandler extends AbstractMessageProducingHandler
AbstractMessageProducingHandler
extension for the mocking purpose in tests.
The provided Consumer
s and Function
s 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 |
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_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, updateNotPropagatedHeaders
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
afterPropertiesSet, 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, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThisAs
getBeanName, getComponentName
protected 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