use of io.eventuate.tram.messaging.consumer.MessageConsumer in project eventuate-tram-core by eventuate-tram.
the class DomainEventDispatcherTest method shouldDispatchMessage.
@Test
public void shouldDispatchMessage() {
MyTarget target = new MyTarget();
MessageConsumer messageConsumer = mock(MessageConsumer.class);
DomainEventDispatcher dispatcher = new DomainEventDispatcher(eventDispatcherId, target.domainEventHandlers(), messageConsumer);
dispatcher.initialize();
dispatcher.messageHandler(DomainEventPublisherImpl.makeMessageForDomainEvent(aggregateType, aggregateId, Collections.singletonMap(Message.ID, messageId), new MyDomainEvent()));
DomainEventEnvelope<?> dee = target.queue.peek();
assertNotNull(dee);
assertEquals(aggregateId, dee.getAggregateId());
assertEquals(aggregateType, dee.getAggregateType());
assertEquals(messageId, dee.getEventId());
}
use of io.eventuate.tram.messaging.consumer.MessageConsumer 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