Search in sources :

Example 1 with CommandStatus

use of io.spine.core.CommandStatus 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.ACommand.createProject();
    final CommandStatus status = CommandStatus.RECEIVED;
    final CommandRecord record = newRecordBuilder(command, status, null).build();
    checkRecord(record, command, status);
}
Also used : Command(io.spine.core.Command) CommandStatus(io.spine.core.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) Test(org.junit.Test)

Example 2 with CommandStatus

use of io.spine.core.CommandStatus 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.ACommand.createProject();
    final CommandStatus status = RECEIVED;
    final CommandRecord record = newRecordBuilder(command, status, null).build();
    checkRecord(record, command, status);
}
Also used : Command(io.spine.core.Command) CommandStatus(io.spine.core.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 3 with CommandStatus

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

Example 4 with CommandStatus

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

Aggregations

Command (io.spine.core.Command)4 CommandStatus (io.spine.core.CommandStatus)4 CommandRecord (io.spine.server.commandbus.CommandRecord)4 Test (org.junit.Test)4 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)3 CommandId (io.spine.core.CommandId)1