use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CommandStoreShould method getProcessingStatus.
private ProcessingStatus getProcessingStatus(CommandEnvelope commandEnvelope) {
final TenantId tenantId = commandEnvelope.getCommandContext().getActorContext().getTenantId();
final TenantAwareFunction<CommandId, ProcessingStatus> func = new TenantAwareFunction<CommandId, ProcessingStatus>(tenantId) {
@Override
public ProcessingStatus apply(@Nullable CommandId input) {
return commandStore.getStatus(checkNotNull(input));
}
};
final ProcessingStatus result = func.execute(commandEnvelope.getId());
return result;
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CommandStoreShould method set_command_status_to_OK_when_handler_returns.
@Test
public void set_command_status_to_OK_when_handler_returns() {
commandBus.register(createProjectHandler);
final Command command = requestFactory.command().create(createProjectMessage());
commandBus.post(command, observer);
final TenantId tenantId = command.getContext().getActorContext().getTenantId();
final CommandId commandId = command.getId();
final ProcessingStatus status = getStatus(commandId, tenantId);
assertEquals(CommandStatus.OK, status.getCode());
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CommandStoreShould method set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed.
@Test
public void set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed() {
final List<Command> commands = newArrayList(createProject(), addTask(), startProject());
final Duration delay = fromMinutes(5);
// time to post passed
final Timestamp schedulingTime = TimeTests.Past.minutesAgo(10);
storeAsScheduled(commands, delay, schedulingTime);
commandBus.rescheduleCommands();
for (Command cmd : commands) {
final CommandEnvelope envelope = CommandEnvelope.of(cmd);
final Message msg = envelope.getMessage();
final CommandId id = envelope.getId();
// Check the expired status error was set.
final ProcessingStatus status = getProcessingStatus(envelope);
// Check that the logging was called.
verify(log).errorExpiredCommand(msg, id);
final Error expected = CommandExpiredException.commandExpired(cmd);
assertEquals(expected, status.getError());
}
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class StorageShould method store_and_read_command.
// We get right after we store.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void store_and_read_command() {
final Command command = Given.ACommand.createProject();
final CommandId commandId = command.getId();
repository.store(command);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, RECEIVED);
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_status.
// We get right after we store.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void store_command_with_status() {
final Command command = Given.ACommand.createProject();
final CommandId commandId = command.getId();
final CommandStatus status = SCHEDULED;
repository.store(command, status);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, status);
}
Aggregations