use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandSchedulingShould method update_scheduling_time.
@Test
public void update_scheduling_time() {
final Command cmd = requestFactory.command().create(toMessage(newUuid()));
final Timestamp schedulingTime = getCurrentTime();
final Command cmdUpdated = CommandScheduler.setSchedulingTime(cmd, schedulingTime);
assertEquals(schedulingTime, cmdUpdated.getSystemProperties().getSchedulingTime());
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandSchedulingShould method not_schedule_command_if_no_scheduling_options_are_set.
@Test
public void not_schedule_command_if_no_scheduling_options_are_set() {
commandBus.register(new CreateProjectHandler());
final Command command = createProject();
commandBus.post(command, observer);
verify(scheduler, never()).schedule(createProject());
checkResult(command);
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandStoreShould method set_command_status_to_error_when_handler_throws_unknown_Throwable.
@Test
public void set_command_status_to_error_when_handler_throws_unknown_Throwable() throws TestRejection, TestThrowable {
ModelTests.clearModel();
final Throwable throwable = new TestThrowable("Unexpected Throwable");
final Command command = givenThrowingHandler(throwable);
final CommandEnvelope envelope = CommandEnvelope.of(command);
commandBus.post(command, observer);
// Check that the logging was called.
verify(log).errorHandlingUnknown(eq(throwable), eq(envelope.getMessage()), eq(envelope.getId()));
// Check that the status and message.
assertHasErrorStatusWithMessage(envelope, throwable.getMessage());
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandStoreShould method set_command_status_to_rejection_when_handler_throws_rejection.
@Test
public void set_command_status_to_rejection_when_handler_throws_rejection() {
ModelTests.clearModel();
final TestRejection rejection = new TestRejection();
final Command command = givenThrowingHandler(rejection);
final CommandId commandId = command.getId();
final Message commandMessage = getMessage(command);
commandBus.post(command, observer);
// Check that the logging was called.
verify(log).rejectedWith(eq(rejection), eq(commandMessage), eq(commandId));
// Check that the status has the correct code,
// and the rejection matches the thrown rejection.
final TenantId tenantId = command.getContext().getActorContext().getTenantId();
final ProcessingStatus status = getStatus(commandId, tenantId);
assertEquals(CommandStatus.REJECTED, status.getCode());
assertEquals(toRejection(rejection, command).getMessage(), status.getRejection().getMessage());
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandStoreShould method givenThrowingHandler.
private <E extends Throwable> Command givenThrowingHandler(E throwable) {
final CommandHandler handler = new ThrowingCreateProjectHandler(throwable);
commandBus.register(handler);
final CmdCreateProject msg = createProjectMessage();
final Command command = requestFactory.command().create(msg);
return command;
}
Aggregations