Search in sources :

Example 6 with ProjectId

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

the class PmMessageDeliveryShould method postpone_events_dispatched_to_reactor_method.

@Test
public void postpone_events_dispatched_to_reactor_method() {
    assertNull(ReactingProjectWizard.getEventReceived());
    final Event event = projectStarted();
    boundedContext.getEventBus().post(event);
    assertNull(ReactingProjectWizard.getEventReceived());
    final EventEnvelope expectedEnvelope = EventEnvelope.of(event);
    final PostponingEventDelivery delivery = repository.getEventEndpointDelivery();
    final Map<ProjectId, EventEnvelope> postponedEvents = delivery.getPostponedEvents();
    assertTrue(postponedEvents.size() == 1 && postponedEvents.containsValue(expectedEnvelope));
    final ProjectId projectId = postponedEvents.keySet().iterator().next();
    delivery.deliverNow(projectId, postponedEvents.get(projectId));
    final PmProjectStarted deliveredEventMsg = ReactingProjectWizard.getEventReceived();
    assertNotNull(deliveredEventMsg);
    assertEquals(Events.getMessage(event), deliveredEventMsg);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) ProjectId(io.spine.test.procman.ProjectId) Event(io.spine.core.Event) PmProjectStarted(io.spine.test.procman.event.PmProjectStarted) PostponingEventDelivery(io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingEventDelivery) Test(org.junit.Test)

Example 7 with ProjectId

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

the class ProcessManagerRepositoryShould method post_command_rejections.

@Test
public void post_command_rejections() {
    final ProjectId id = ProjectId.newBuilder().setId(newUuid()).build();
    final PmThrowEntityAlreadyArchived commandMsg = PmThrowEntityAlreadyArchived.newBuilder().setProjectId(id).build();
    final Command command = requestFactory.createCommand(commandMsg);
    repository().dispatchCommand(CommandEnvelope.of(command));
    final StandardRejections.EntityAlreadyArchived expected = StandardRejections.EntityAlreadyArchived.newBuilder().setEntityId(AnyPacker.pack(id)).build();
    assertTrue(TestProcessManager.processed(expected));
}
Also used : PmThrowEntityAlreadyArchived(io.spine.test.procman.command.PmThrowEntityAlreadyArchived) StandardRejections(io.spine.server.entity.rejection.StandardRejections) Command(io.spine.core.Command) ProjectId(io.spine.test.procman.ProjectId) EntityAlreadyArchived(io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived) Test(org.junit.Test)

Example 8 with ProjectId

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

the class ProcessManagerRepositoryShould method dispatch_command_to_deleted_process_manager.

@Test
public void dispatch_command_to_deleted_process_manager() throws InvocationTargetException {
    final PmArchiveProcess archiveProcess = archiveProcess();
    testDispatchCommand(archiveProcess);
    final ProjectId projectId = archiveProcess.getProjectId();
    TestProcessManager processManager = repository().findOrCreate(projectId);
    assertTrue(processManager.isArchived());
    // Dispatch a command to the archived 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.isArchived());
}
Also used : Task(io.spine.test.procman.Task) GivenCommandMessage.addTask(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.GivenCommandMessage.addTask) TestProcessManager(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager) PmArchiveProcess(io.spine.test.procman.command.PmArchiveProcess) ProjectId(io.spine.test.procman.ProjectId) Test(org.junit.Test)

Example 9 with ProjectId

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

the class ProcessManagerRepositoryShould method dispatch_event_to_deleted_process_manager.

@Test
public void dispatch_event_to_deleted_process_manager() throws InvocationTargetException {
    final PmDeleteProcess deleteProcess = deleteProcess();
    testDispatchCommand(deleteProcess);
    final ProjectId projectId = deleteProcess.getProjectId();
    TestProcessManager processManager = repository().findOrCreate(projectId);
    assertTrue(processManager.isDeleted());
    // Dispatch an event to the deleted process manager.
    testDispatchEvent(taskAdded());
    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)

Example 10 with ProjectId

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

the class ProcessManagerRepositoryShould method createEntity.

@Override
protected TestProcessManager createEntity() {
    final ProjectId id = ProjectId.newBuilder().setId(newUuid()).build();
    final TestProcessManager result = Given.processManagerOfClass(TestProcessManager.class).withId(id).build();
    return result;
}
Also used : TestProcessManager(io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager) ProjectId(io.spine.test.procman.ProjectId)

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