Search in sources :

Example 1 with CommandRecord

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());
}
Also used : Command(io.spine.base.Command) Error(io.spine.base.Error) CommandId(io.spine.base.CommandId) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 2 with CommandRecord

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);
}
Also used : Command(io.spine.base.Command) CommandStatus(io.spine.base.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 3 with CommandRecord

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();
}
Also used : Command(io.spine.base.Command) Identifiers.idToString(io.spine.base.Identifiers.idToString) CommandRecord(io.spine.server.commandbus.CommandRecord)

Example 4 with CommandRecord

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));
    }
}
Also used : Command(io.spine.base.Command) CommandStatus(io.spine.base.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 5 with CommandRecord

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);
}
Also used : Command(io.spine.base.Command) CommandStatus(io.spine.base.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) Test(org.junit.Test)

Aggregations

CommandRecord (io.spine.server.commandbus.CommandRecord)17 Test (org.junit.Test)10 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)9 Command (io.spine.base.Command)8 CommandStatus (io.spine.base.CommandStatus)4 CommandId (io.spine.base.CommandId)3 Error (io.spine.base.Error)3 Identifiers.idToString (io.spine.base.Identifiers.idToString)2 Failure (io.spine.base.Failure)1 TestActorRequestFactory (io.spine.test.TestActorRequestFactory)1