Search in sources :

Example 1 with PmCreateProject

use of io.spine.test.procman.command.PmCreateProject 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);
}
Also used : Command(io.spine.core.Command) PmCreateProject(io.spine.test.procman.command.PmCreateProject) PostponingCommandDelivery(io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingCommandDelivery) ProjectId(io.spine.test.procman.ProjectId) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Aggregations

Command (io.spine.core.Command)1 CommandEnvelope (io.spine.core.CommandEnvelope)1 PostponingCommandDelivery (io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingCommandDelivery)1 ProjectId (io.spine.test.procman.ProjectId)1 PmCreateProject (io.spine.test.procman.command.PmCreateProject)1 Test (org.junit.Test)1