use of io.spine.core.Command in project core-java by SpineEventEngine.
the class StorageShould method newStorageRecord.
private static CommandRecord newStorageRecord() {
final Command command = Given.ACommand.createProject();
final String commandType = CommandEnvelope.of(command).getTypeName().value();
final CommandRecord.Builder builder = CommandRecord.newBuilder().setCommandType(commandType).setCommandId(command.getId()).setCommand(command).setTimestamp(getCurrentTime()).setStatus(ProcessingStatus.newBuilder().setCode(RECEIVED));
return builder.build();
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_error_and_generate_ID_if_needed.
@Test
public void store_command_with_error_and_generate_ID_if_needed() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final Command command = factory.createCommand(createProjectMessage());
final Error error = newError();
repository.store(command, error);
final List<CommandRecord> records = Lists.newArrayList(repository.iterator(ERROR));
assertEquals(1, records.size());
final String commandIdStr = Identifier.toString(records.get(0).getCommandId());
assertFalse(commandIdStr.isEmpty());
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class StorageShould method load_commands_by_status.
@Test
public void load_commands_by_status() {
final List<Command> commands = ImmutableList.of(Given.ACommand.createProject(), Given.ACommand.addTask(), Given.ACommand.startProject());
final CommandStatus status = SCHEDULED;
store(commands, status);
// store an extra command with another status
repository.store(Given.ACommand.createProject(), ERROR);
final Iterator<CommandRecord> iterator = repository.iterator(status);
final List<Command> actualCommands = newArrayList(toCommandIterator(iterator));
assertEquals(commands.size(), actualCommands.size());
for (Command cmd : actualCommands) {
assertTrue(commands.contains(cmd));
}
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_error.
// We get right after we store.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void store_command_with_error() {
final Command command = Given.ACommand.createProject();
final CommandId commandId = command.getId();
final Error error = newError();
repository.store(command, error);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, ERROR);
assertEquals(error, record.getStatus().getError());
}
use of io.spine.core.Command in project core-java by SpineEventEngine.
the class CommandEnvelopeShould method obtain_command_context.
@Test
public void obtain_command_context() {
final Command command = outerObject();
final CommandEnvelope envelope = toEnvelope(command);
assertEquals(command.getContext(), envelope.getCommandContext());
assertSame(envelope.getCommandContext(), envelope.getMessageContext());
}
Aggregations