use of io.spine.test.procman.command.PmStartProject in project core-java by SpineEventEngine.
the class ProcessManagerShould method route_commands.
/**
* Tests command routing.
*
* @see TestProcessManager#handle(PmStartProject, CommandContext)
*/
@Test
public void route_commands() {
// Add dispatcher for the routed command. Otherwise the command would reject the command.
final AddTaskDispatcher dispatcher = new AddTaskDispatcher();
commandBus.register(dispatcher);
processManager.injectCommandBus(commandBus);
final List<Event> events = testDispatchCommand(startProject());
// There's only one event generated.
assertEquals(1, events.size());
final Event event = events.get(0);
// The producer of the event is our Process Manager.
assertEquals(processManager.getId(), Events.getProducer(event.getContext()));
final Message message = AnyPacker.unpack(event.getMessage());
// The event type is CommandRouted.
assertThat(message, instanceOf(CommandRouted.class));
final CommandRouted commandRouted = (CommandRouted) message;
// The source of the command is StartProject.
assertThat(getMessage(commandRouted.getSource()), instanceOf(PmStartProject.class));
final List<CommandEnvelope> dispatchedCommands = dispatcher.getCommands();
assertSize(1, dispatchedCommands);
final CommandEnvelope dispatchedCommand = dispatcher.getCommands().get(0);
assertEquals(commandRouted.getProduced(0), dispatchedCommand.getCommand());
}
use of io.spine.test.procman.command.PmStartProject in project core-java by SpineEventEngine.
the class PmMessageDeliveryTestEnv method cannotStartProject.
public static Rejection cannotStartProject() {
final ProjectId projectId = projectId();
final PmStartProject cmdMessage = PmStartProject.newBuilder().setProjectId(projectId).build();
final Command command = createCommand(cmdMessage);
final Rejection result = toRejection(throwableWith(projectId), command);
return result;
}
Aggregations