Search in sources :

Example 41 with Command

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

the class MultiTenantCommandBusShould method store_command_when_posted.

@Test
public void store_command_when_posted() {
    commandBus.register(createProjectHandler);
    final Command cmd = createProject();
    commandBus.post(cmd, observer);
    verify(commandStore).store(cmd);
}
Also used : Command(io.spine.core.Command) Test(org.junit.Test)

Example 42 with Command

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

the class MultiTenantCommandBusShould method store_invalid_command_with_error_status.

@Test
public void store_invalid_command_with_error_status() {
    commandBus.register(createProjectHandler);
    final Command cmd = newCommandWithoutContext();
    commandBus.post(cmd, observer);
    verify(commandStore).store(eq(cmd), isA(Error.class));
}
Also used : Command(io.spine.core.Command) Error(io.spine.base.Error) CommandValidationError(io.spine.core.CommandValidationError) Test(org.junit.Test)

Example 43 with Command

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

the class SingleTenantCommandBusShould method propagate_rejections_to_rejection_bus.

@Test
public void propagate_rejections_to_rejection_bus() {
    final FaultyHandler faultyHandler = new FaultyHandler(eventBus);
    commandBus.register(faultyHandler);
    final Command addTaskCommand = clearTenantId(addTask());
    final MemoizingObserver<Ack> observer = memoizingObserver();
    commandBus.post(addTaskCommand, observer);
    final InvalidProjectName throwable = faultyHandler.getThrowable();
    final Rejection expectedRejection = toRejection(throwable, addTaskCommand);
    final Ack ack = observer.firstResponse();
    final Rejection actualRejection = ack.getStatus().getRejection();
    assertTrue(isNotDefault(actualRejection));
    assertEquals(unpack(expectedRejection.getMessage()), unpack(actualRejection.getMessage()));
}
Also used : Rejections.toRejection(io.spine.core.Rejections.toRejection) Rejection(io.spine.core.Rejection) Command(io.spine.core.Command) InvalidProjectName(io.spine.test.reflect.InvalidProjectName) Ack(io.spine.core.Ack) Test(org.junit.Test)

Example 44 with Command

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

the class RecordsShould method convert_cmd_to_record.

/*
     * Conversion tests.
     *******************/
@Test
public void convert_cmd_to_record() {
    final Command command = Given.ACommand.createProject();
    final CommandStatus status = CommandStatus.RECEIVED;
    final CommandRecord record = newRecordBuilder(command, status, null).build();
    checkRecord(record, command, status);
}
Also used : Command(io.spine.core.Command) CommandStatus(io.spine.core.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) Test(org.junit.Test)

Example 45 with Command

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

the class StorageShould method convert_cmd_to_record.

/*
     * Conversion tests.
     *******************/
@Test
public void convert_cmd_to_record() {
    final Command command = Given.ACommand.createProject();
    final CommandStatus status = RECEIVED;
    final CommandRecord record = newRecordBuilder(command, status, null).build();
    checkRecord(record, command, status);
}
Also used : Command(io.spine.core.Command) CommandStatus(io.spine.core.CommandStatus) CommandRecord(io.spine.server.commandbus.CommandRecord) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) 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