Search in sources :

Example 11 with CommandRecord

use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.

the class Entity method setToFailure.

void setToFailure(Failure failure) {
    final CommandRecord.Builder builder = getState().toBuilder();
    builder.getStatusBuilder().setCode(FAILURE).setFailure(failure);
    final CommandRecord record = builder.build();
    updateState(record);
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord)

Example 12 with CommandRecord

use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.

the class Entity method setError.

private void setError(CommandId id, Command command, Error error) {
    final CommandRecord.Builder builder = Records.newRecordBuilder(command, ERROR, id);
    builder.getStatusBuilder().setError(error);
    final CommandRecord record = builder.build();
    updateState(record);
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord)

Example 13 with CommandRecord

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

Example 14 with CommandRecord

use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.

the class StorageShould method set_failure_command_status.

// We get right after we update status.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void set_failure_command_status() {
    givenNewRecord();
    final Failure failure = newFailure();
    storage.updateStatus(id, failure);
    final CommandRecord actual = read(id).get();
    assertEquals(FAILURE, actual.getStatus().getCode());
    assertEquals(failure, actual.getStatus().getFailure());
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord) Failure(io.spine.base.Failure) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 15 with CommandRecord

use of io.spine.server.commandbus.CommandRecord in project core-java by SpineEventEngine.

the class StorageShould method set_ok_command_status.

/*
     * Update command status tests.
     ******************************/
// We get right after we update status.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void set_ok_command_status() {
    givenNewRecord();
    storage.setOkStatus(id);
    final CommandRecord actual = read(id).get();
    assertEquals(OK, actual.getStatus().getCode());
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) 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