Search in sources :

Example 16 with CommandRecord

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

the class Entity method setToError.

void setToError(Error error) {
    final CommandRecord.Builder builder = getState().toBuilder();
    builder.getStatusBuilder().setCode(ERROR).setError(error);
    final CommandRecord record = builder.build();
    updateState(record);
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord)

Example 17 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 18 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();
    repository.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)

Example 19 with CommandRecord

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

the class StorageShould method store_and_read_command.

// We get right after we store.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void store_and_read_command() {
    final Command command = Given.ACommand.createProject();
    final CommandId commandId = command.getId();
    repository.store(command);
    final CommandRecord record = read(commandId).get();
    checkRecord(record, command, RECEIVED);
}
Also used : Command(io.spine.core.Command) CommandId(io.spine.core.CommandId) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 20 with CommandRecord

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

the class StorageShould method set_rejected_command_status.

// We get right after we update status.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void set_rejected_command_status() {
    givenNewRecord();
    final Rejection rejection = newRejection();
    repository.updateStatus(id, rejection);
    final CommandRecord actual = read(id).get();
    assertEquals(REJECTED, actual.getStatus().getCode());
    assertEquals(rejection, actual.getStatus().getRejection());
}
Also used : Rejection(io.spine.core.Rejection) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Aggregations

CommandRecord (io.spine.server.commandbus.CommandRecord)23 Test (org.junit.Test)11 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)10 Command (io.spine.core.Command)8 CommandStatus (io.spine.core.CommandStatus)4 Error (io.spine.base.Error)3 CommandId (io.spine.core.CommandId)3 Failure (io.spine.base.Failure)1 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)1 Rejection (io.spine.core.Rejection)1