Search in sources :

Example 86 with Command

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

the class SingleTenantCommandBusShould method reject_multitenant_command_in_single_tenant_context.

@Test
public void reject_multitenant_command_in_single_tenant_context() {
    // Create a multi-tenant command.
    final Command cmd = createProject();
    commandBus.post(cmd, observer);
    checkCommandError(observer.firstResponse(), TENANT_INAPPLICABLE, InvalidCommandException.class, cmd);
}
Also used : Command(io.spine.core.Command) Test(org.junit.Test)

Example 87 with Command

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

the class SingleTenantCommandBusShould method reject_invalid_command.

@Test
public void reject_invalid_command() {
    final Command cmd = newCommandWithoutContext();
    commandBus.post(cmd, observer);
    checkCommandError(observer.firstResponse(), INVALID_COMMAND, CommandValidationError.getDescriptor().getFullName(), cmd);
}
Also used : Command(io.spine.core.Command) Test(org.junit.Test)

Example 88 with Command

use of io.spine.core.Command 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 89 with Command

use of io.spine.core.Command 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 90 with Command

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

the class CommandEnvelopeShould method obtain_actor_context.

@Test
public void obtain_actor_context() {
    final Command command = outerObject();
    final CommandEnvelope envelope = toEnvelope(command);
    assertEquals(command.getContext().getActorContext(), envelope.getActorContext());
}
Also used : Command(io.spine.core.Command) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Aggregations

Command (io.spine.core.Command)137 Test (org.junit.Test)87 Event (io.spine.core.Event)19 TenantId (io.spine.core.TenantId)17 Ack (io.spine.core.Ack)15 Message (com.google.protobuf.Message)14 Rejection (io.spine.core.Rejection)13 CommandEnvelope (io.spine.core.CommandEnvelope)11 Timestamp (com.google.protobuf.Timestamp)9 Error (io.spine.base.Error)9 CommandContext (io.spine.core.CommandContext)9 AggregateMessageDispatcher.dispatchCommand (io.spine.server.aggregate.AggregateMessageDispatcher.dispatchCommand)8 CommandRecord (io.spine.server.commandbus.CommandRecord)8 ProjectId (io.spine.test.aggregate.ProjectId)8 CommandBus (io.spine.server.commandbus.CommandBus)7 GivenEvent (io.spine.server.event.given.EventBusTestEnv.GivenEvent)7 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)7 Any (com.google.protobuf.Any)6 CommandId (io.spine.core.CommandId)6 AggregateTestEnv.newTenantId (io.spine.server.aggregate.given.aggregate.AggregateTestEnv.newTenantId)6