use of io.spine.base.CommandId in project core-java by SpineEventEngine.
the class TestEventFactory method newInstance.
public static TestEventFactory newInstance(Any producerId, TestActorRequestFactory requestFactory) {
checkNotNull(requestFactory);
final CommandContext commandContext = requestFactory.createCommandContext();
final CommandId commandId = requestFactory.createCommandId();
final Builder builder = EventFactory.newBuilder().setProducerId(producerId).setCommandContext(commandContext).setCommandId(commandId);
final TestEventFactory result = new TestEventFactory(builder);
return result;
}
use of io.spine.base.CommandId in project core-java by SpineEventEngine.
the class CommandScheduler method rememberAsScheduled.
private static void rememberAsScheduled(Command command) {
final CommandId id = command.getId();
scheduledCommandIds.add(id);
}
use of io.spine.base.CommandId in project core-java by SpineEventEngine.
the class Rescheduler method onScheduledCommandExpired.
/**
* Sets the status of the expired command to error.
*
* <p>We cannot post such a command because there is no handler or dispatcher registered yet.
* Or, posting such a command may be undesirable from the business logic point of view.
*
* @param command the expired command
* @see CommandExpiredException
*/
private void onScheduledCommandExpired(Command command) {
final CommandEnvelope commandEnvelope = CommandEnvelope.of(command);
final Message msg = commandEnvelope.getMessage();
final CommandId id = commandEnvelope.getCommandId();
final Error error = CommandExpiredException.commandExpiredError(msg);
commandStore().setToError(commandEnvelope, error);
log().errorExpiredCommand(msg, id);
}
use of io.spine.base.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.Command.createProject();
final CommandId commandId = command.getId();
final CommandStatus status = SCHEDULED;
storage.store(command, status);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, status);
}
use of io.spine.base.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.Command.createProject();
final CommandId commandId = command.getId();
storage.store(command);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, RECEIVED);
}
Aggregations