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);
}
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);
}
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));
}
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;
}
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());
}
Aggregations