use of io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingCommandDelivery in project core-java by SpineEventEngine.
the class PmMessageDeliveryShould method postpone_commands_dispatched_to_command_subscriber_method.
@Test
public void postpone_commands_dispatched_to_command_subscriber_method() {
assertNull(ReactingProjectWizard.getCommandReceived());
final Command command = createProject();
boundedContext.getCommandBus().post(command, StreamObservers.<Ack>noOpObserver());
assertNull(ReactingProjectWizard.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 PmCreateProject deliveredCommandMsg = ReactingProjectWizard.getCommandReceived();
assertNotNull(deliveredCommandMsg);
assertEquals(Commands.getMessage(command), deliveredCommandMsg);
}
Aggregations