use of io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingCommandDelivery in project core-java by SpineEventEngine.
the class AggregateMessageDeliveryShould method postpone_commands_dispatched_to_command_handler_method.
@Test
public void postpone_commands_dispatched_to_command_handler_method() {
assertNull(ReactingProject.getCommandReceived());
final Command command = createProject();
boundedContext.getCommandBus().post(command, StreamObservers.<Ack>noOpObserver());
assertNull(ReactingProject.getCommandReceived());
final CommandEnvelope expectedEnvelope = CommandEnvelope.of(command);
final PostponingCommandDelivery delivery = repository.getCommandEndpointDelivery();
final Map<ProjectId, CommandEnvelope> postponedCommands = delivery.getPostponedCommands();
assertTrue(postponedCommands.size() == 1 && postponedCommands.containsValue(expectedEnvelope));
final ProjectId projectId = postponedCommands.keySet().iterator().next();
delivery.deliverNow(projectId, postponedCommands.get(projectId));
final AggCreateProject deliveredCommandMsg = ReactingProject.getCommandReceived();
assertNotNull(deliveredCommandMsg);
assertEquals(Commands.getMessage(command), deliveredCommandMsg);
}
Aggregations