use of io.spine.server.commandbus.CommandRecord 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.Command.createProject();
final CommandId commandId = command.getId();
final Error error = newError();
storage.store(command, error);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, ERROR);
assertEquals(error, record.getStatus().getError());
}
use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.
the class StorageShould method convert_cmd_to_record.
/*
* Conversion tests.
*******************/
@Test
public void convert_cmd_to_record() {
final Command command = Given.Command.createProject();
final CommandStatus status = RECEIVED;
final CommandRecord record = newRecordBuilder(command, status, null).build();
checkRecord(record, command, status);
}
use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.
the class StorageShould method newStorageRecord.
private static CommandRecord newStorageRecord() {
final Command command = Given.Command.createProject();
final String commandType = TypeName.ofCommand(command).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.server.commandbus.CommandRecord 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.Command.createProject(), Given.Command.addTask(), Given.Command.startProject());
final CommandStatus status = SCHEDULED;
store(commands, status);
// store an extra command with another status
storage.store(Given.Command.createProject(), ERROR);
final Iterator<CommandRecord> iterator = storage.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.server.commandbus.CommandRecord in project core-java by SpineEventEngine.
the class RecordsShould method convert_cmd_to_record.
/*
* Conversion tests.
*******************/
@Test
public void convert_cmd_to_record() {
final Command command = Given.Command.createProject();
final CommandStatus status = CommandStatus.RECEIVED;
final CommandRecord record = newRecordBuilder(command, status, null).build();
checkRecord(record, command, status);
}
Aggregations