use of io.eventuate.tram.commands.common.ChannelMapping in project eventuate-tram-core by eventuate-tram.
the class CommandDispatcherTest method shouldDispatchCommand.
@Test
public void shouldDispatchCommand() {
String commandDispatcherId = "fooId";
CommandDispatcherTestTarget target = spy(new CommandDispatcherTestTarget());
ChannelMapping channelMapping = mock(ChannelMapping.class);
MessageConsumer messageConsumer = mock(MessageConsumer.class);
MessageProducer messageProducer = mock(MessageProducer.class);
CommandDispatcher dispatcher = new CommandDispatcher(commandDispatcherId, defineCommandHandlers(target), channelMapping, messageConsumer, messageProducer);
String customerId = "customer0";
String resource = "/customers/" + customerId;
Command command = new TestCommand();
String replyTo = "replyTo-xxx";
String channel = "myChannel";
Message message = CommandProducerImpl.makeMessage(channel, resource, command, replyTo, singletonMap(Message.ID, "999"));
dispatcher.messageHandler(message);
verify(target).reserveCredit(any(CommandMessage.class), any(PathVariables.class));
verify(messageProducer).send(any(), any());
verifyNoMoreInteractions(messageProducer, target);
}
Aggregations