Search in sources :

Example 1 with MessageProducer

use of io.eventuate.tram.messaging.producer.MessageProducer 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);
}
Also used : MessageConsumer(io.eventuate.tram.messaging.consumer.MessageConsumer) Message(io.eventuate.tram.messaging.common.Message) Command(io.eventuate.tram.commands.common.Command) ChannelMapping(io.eventuate.tram.commands.common.ChannelMapping) MessageProducer(io.eventuate.tram.messaging.producer.MessageProducer) Test(org.junit.Test)

Aggregations

ChannelMapping (io.eventuate.tram.commands.common.ChannelMapping)1 Command (io.eventuate.tram.commands.common.Command)1 Message (io.eventuate.tram.messaging.common.Message)1 MessageConsumer (io.eventuate.tram.messaging.consumer.MessageConsumer)1 MessageProducer (io.eventuate.tram.messaging.producer.MessageProducer)1 Test (org.junit.Test)1