Search in sources :

Example 21 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.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)

Example 22 with CommandRecord

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

the class CEntity method setToRejected.

void setToRejected(Rejection rejection) {
    final CommandRecord.Builder builder = getState().toBuilder();
    builder.getStatusBuilder().setCode(REJECTED).setRejection(rejection);
    final CommandRecord record = builder.build();
    updateState(record);
}
Also used : CommandRecord(io.spine.server.commandbus.CommandRecord)

Example 23 with CommandRecord

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

the class CEntity 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)

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