Search in sources :

Example 1 with TestProcessManager

use of io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager 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 2 with TestProcessManager

use of io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager 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)

Example 3 with TestProcessManager

use of io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager 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 4 with TestProcessManager

use of io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager 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 5 with TestProcessManager

use of io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager 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

TestProcessManager (io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.TestProcessManager)6 ProjectId (io.spine.test.procman.ProjectId)6 GivenCommandMessage.addTask (io.spine.server.procman.given.ProcessManagerRepositoryTestEnv.GivenCommandMessage.addTask)4 Task (io.spine.test.procman.Task)4 Test (org.junit.Test)4 PmArchiveProcess (io.spine.test.procman.command.PmArchiveProcess)2 PmDeleteProcess (io.spine.test.procman.command.PmDeleteProcess)2