Search in sources :

Example 11 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class TestEventFactory method newInstance.

public static TestEventFactory newInstance(Any producerId, TestActorRequestFactory requestFactory) {
    checkNotNull(requestFactory);
    final CommandContext commandContext = requestFactory.createCommandContext();
    final CommandId commandId = requestFactory.createCommandId();
    final Builder builder = EventFactory.newBuilder().setProducerId(producerId).setCommandContext(commandContext).setCommandId(commandId);
    final TestEventFactory result = new TestEventFactory(builder);
    return result;
}
Also used : CommandContext(io.spine.base.CommandContext) CommandId(io.spine.base.CommandId)

Example 12 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class CommandScheduler method rememberAsScheduled.

private static void rememberAsScheduled(Command command) {
    final CommandId id = command.getId();
    scheduledCommandIds.add(id);
}
Also used : CommandId(io.spine.base.CommandId)

Example 13 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class Rescheduler method onScheduledCommandExpired.

/**
     * Sets the status of the expired command to error.
     *
     * <p>We cannot post such a command because there is no handler or dispatcher registered yet.
     * Or, posting such a command may be undesirable from the business logic point of view.
     *
     * @param command the expired command
     * @see CommandExpiredException
     */
private void onScheduledCommandExpired(Command command) {
    final CommandEnvelope commandEnvelope = CommandEnvelope.of(command);
    final Message msg = commandEnvelope.getMessage();
    final CommandId id = commandEnvelope.getCommandId();
    final Error error = CommandExpiredException.commandExpiredError(msg);
    commandStore().setToError(commandEnvelope, error);
    log().errorExpiredCommand(msg, id);
}
Also used : Message(com.google.protobuf.Message) CommandEnvelope(io.spine.envelope.CommandEnvelope) Error(io.spine.base.Error) CommandId(io.spine.base.CommandId)

Example 14 with CommandId

use of io.spine.base.CommandId 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 15 with CommandId

use of io.spine.base.CommandId 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.Command.createProject();
    final CommandId commandId = command.getId();
    storage.store(command);
    final CommandRecord record = read(commandId).get();
    checkRecord(record, command, RECEIVED);
}
Also used : Command(io.spine.base.Command) CommandId(io.spine.base.CommandId) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Aggregations

CommandId (io.spine.base.CommandId)20 Test (org.junit.Test)7 Command (io.spine.base.Command)6 Message (com.google.protobuf.Message)5 Error (io.spine.base.Error)4 CommandRecord (io.spine.server.commandbus.CommandRecord)4 CommandContext (io.spine.base.CommandContext)3 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)3 TenantId (io.spine.users.TenantId)3 Commands.getMessage (io.spine.base.Commands.getMessage)2 CommandEnvelope (io.spine.envelope.CommandEnvelope)2 CommandMessage.createProjectMessage (io.spine.server.commandbus.Given.CommandMessage.createProjectMessage)2 AbstractEntity (io.spine.server.entity.AbstractEntity)2 Nullable (javax.annotation.Nullable)2 ImmutableList (com.google.common.collect.ImmutableList)1 Duration (com.google.protobuf.Duration)1 Timestamp (com.google.protobuf.Timestamp)1 CommandStatus (io.spine.base.CommandStatus)1 FailureThrowable (io.spine.base.FailureThrowable)1 Identifiers.idToString (io.spine.base.Identifiers.idToString)1