use of io.spine.core.Command 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.core.Command in project core-java by SpineEventEngine.
the class ProcessManagerRepositoryShould method throw_exception_if_dispatch_unknown_command.
@Test(expected = IllegalArgumentException.class)
public void throw_exception_if_dispatch_unknown_command() {
final Command unknownCommand = requestFactory.createCommand(Int32Value.getDefaultInstance());
final CommandEnvelope request = CommandEnvelope.of(unknownCommand);
repository().dispatchCommand(request);
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class ProcessManagerShould method entityAlreadyArchived.
private static RejectionEnvelope entityAlreadyArchived(Class<? extends Message> commandMessageCls) {
final Any id = Identifier.pack(ProcessManagerShould.class.getName());
final EntityAlreadyArchived rejectionMessage = EntityAlreadyArchived.newBuilder().setEntityId(id).build();
final Command command = ACommand.withMessage(Sample.messageOfType(commandMessageCls));
final Rejection rejection = Rejections.createRejection(rejectionMessage, command);
return RejectionEnvelope.of(rejection);
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class Given method missingOwnerRejection.
public static Rejection missingOwnerRejection() {
final ProjectId projectId = newProjectId();
final ProjectRejections.MissingOwner msg = ProjectRejections.MissingOwner.newBuilder().setProjectId(projectId).build();
final Command command = io.spine.server.commandbus.Given.ACommand.withMessage(Sample.messageOfType(RjRemoveOwner.class));
return Rejections.createRejection(msg, command);
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class InvalidProjectNameSubscriber method on.
@Subscribe
public void on(InvalidProjectName rejection, RjUpdateProjectName commandMessage, CommandContext context) {
final CommandFactory commandFactory = TestActorRequestFactory.newInstance(InvalidProjectNameSubscriber.class).command();
final Command command = commandFactory.createWithContext(commandMessage, context);
this.rejectionHandled = Rejections.createRejection(rejection, command);
}
Aggregations