Search in sources :

Example 1 with ProjectId

use of io.spine.test.procman.ProjectId in project core-java by SpineEventEngine.

the class PmMessageDeliveryShould method postpone_rejections_dispatched_to_reactor_method.

@Test
public void postpone_rejections_dispatched_to_reactor_method() {
    assertNull(ReactingProjectWizard.getEventReceived());
    final Rejection rejection = cannotStartProject();
    boundedContext.getRejectionBus().post(rejection);
    assertNull(ReactingProjectWizard.getRejectionReceived());
    final RejectionEnvelope expectedEnvelope = RejectionEnvelope.of(rejection);
    final PostponingRejectionDelivery delivery = repository.getRejectionEndpointDelivery();
    final Map<ProjectId, RejectionEnvelope> postponedRejections = delivery.getPostponedRejections();
    assertTrue(postponedRejections.size() == 1 && postponedRejections.containsValue(expectedEnvelope));
    final ProjectId projectId = postponedRejections.keySet().iterator().next();
    delivery.deliverNow(projectId, postponedRejections.get(projectId));
    final PmCannotStartArchivedProject deliveredRejectionMsg = ReactingProjectWizard.getRejectionReceived();
    assertNotNull(deliveredRejectionMsg);
    assertEquals(getMessage(rejection), deliveredRejectionMsg);
}
Also used : Rejection(io.spine.core.Rejection) PmCannotStartArchivedProject(io.spine.test.procman.rejection.Rejections.PmCannotStartArchivedProject) ProjectId(io.spine.test.procman.ProjectId) PostponingRejectionDelivery(io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingRejectionDelivery) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 2 with ProjectId

use of io.spine.test.procman.ProjectId 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)

Example 3 with ProjectId

use of io.spine.test.procman.ProjectId in project core-java by SpineEventEngine.

the class ProcessManagerRepositoryShould method dispatch_rejection.

@Test
public void dispatch_rejection() {
    final CommandEnvelope ce = requestFactory.generateEnvelope();
    final EntityAlreadyArchived rejectionMessage = EntityAlreadyArchived.newBuilder().setEntityId(Identifier.pack(newUuid())).build();
    final Rejection rejection = createRejection(rejectionMessage, ce.getCommand());
    final ProjectId id = ProcessManagerRepositoryTestEnv.GivenCommandMessage.ID;
    final Rejection.Builder builder = rejection.toBuilder().setContext(rejection.getContext().toBuilder().setProducerId(Identifier.pack(id)));
    final RejectionEnvelope re = RejectionEnvelope.of(builder.build());
    final Set<?> delivered = repository().dispatchRejection(re);
    assertTrue(delivered.contains(id));
    assertTrue(TestProcessManager.processed(rejectionMessage));
}
Also used : Rejections.createRejection(io.spine.core.Rejections.createRejection) Rejection(io.spine.core.Rejection) ProjectId(io.spine.test.procman.ProjectId) CommandEnvelope(io.spine.core.CommandEnvelope) PmThrowEntityAlreadyArchived(io.spine.test.procman.command.PmThrowEntityAlreadyArchived) EntityAlreadyArchived(io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 4 with ProjectId

use of io.spine.test.procman.ProjectId in project core-java by SpineEventEngine.

the class ProcessManagerRepositoryShould method createEntities.

@Override
protected List<TestProcessManager> createEntities(int count) {
    final List<TestProcessManager> procmans = Lists.newArrayList();
    for (int i = 0; i < count; i++) {
        final ProjectId id = createId(i);
        procmans.add(new TestProcessManager(id));
    }
    return procmans;
}
Also used : TestProcessManager(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager) ProjectId(io.spine.test.procman.ProjectId)

Example 5 with ProjectId

use of io.spine.test.procman.ProjectId in project core-java by SpineEventEngine.

the class ProcessManagerRepositoryShould method dispatch_command_to_archived_process_manager.

@Test
public void dispatch_command_to_archived_process_manager() throws InvocationTargetException {
    final PmDeleteProcess deleteProcess = deleteProcess();
    testDispatchCommand(deleteProcess);
    final ProjectId projectId = deleteProcess.getProjectId();
    TestProcessManager processManager = repository().findOrCreate(projectId);
    assertTrue(processManager.isDeleted());
    // Dispatch a command to the deleted process manager.
    testDispatchCommand(addTask());
    processManager = repository().findOrCreate(projectId);
    final List<Task> addedTasks = processManager.getState().getTaskList();
    assertFalse(addedTasks.isEmpty());
    // Check that the process manager was not re-created before dispatching.
    assertTrue(processManager.isDeleted());
}
Also used : PmDeleteProcess(io.spine.test.procman.command.PmDeleteProcess) Task(io.spine.test.procman.Task) GivenCommandMessage.addTask(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.GivenCommandMessage.addTask) TestProcessManager(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager) ProjectId(io.spine.test.procman.ProjectId) Test(org.junit.Test)

Aggregations

ProjectId (io.spine.test.procman.ProjectId)14 Test (org.junit.Test)9 TestProcessManager (io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager)6 Command (io.spine.core.Command)4 GivenCommandMessage.addTask (io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.GivenCommandMessage.addTask)4 Task (io.spine.test.procman.Task)4 Rejection (io.spine.core.Rejection)3 CommandEnvelope (io.spine.core.CommandEnvelope)2 Event (io.spine.core.Event)2 RejectionEnvelope (io.spine.core.RejectionEnvelope)2 EntityAlreadyArchived (io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived)2 PmArchiveProcess (io.spine.test.procman.command.PmArchiveProcess)2 PmDeleteProcess (io.spine.test.procman.command.PmDeleteProcess)2 PmThrowEntityAlreadyArchived (io.spine.test.procman.command.PmThrowEntityAlreadyArchived)2 PmProjectStarted (io.spine.test.procman.event.PmProjectStarted)2 EventEnvelope (io.spine.core.EventEnvelope)1 Rejections.createRejection (io.spine.core.Rejections.createRejection)1 Rejections.toRejection (io.spine.core.Rejections.toRejection)1 TestEventFactory (io.spine.server.command.TestEventFactory)1 StandardRejections (io.spine.server.entity.rejection.StandardRejections)1