Search in sources :

Example 36 with Command

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

the class CommandValidatorViolationCheckShould method validate_command_and_return_nothing_if_it_is_valid.

@Test
public void validate_command_and_return_nothing_if_it_is_valid() {
    final Command cmd = Given.ACommand.createProject();
    final List<ConstraintViolation> violations = inspect(CommandEnvelope.of(cmd));
    assertEquals(0, violations.size());
}
Also used : Command(io.spine.core.Command) ConstraintViolation(io.spine.validate.ConstraintViolation) Test(org.junit.Test)

Example 37 with Command

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

the class CommandValidatorViolationCheckShould method validate_command_and_return_violations_if_context_is_NOT_valid.

@Test
public void validate_command_and_return_violations_if_context_is_NOT_valid() {
    final Command command = TestActorRequestFactory.newInstance(getClass()).createCommand(createProjectMessage(), Time.getCurrentTime());
    final Command commandWithoutContext = command.toBuilder().setContext(CommandContext.getDefaultInstance()).build();
    final List<ConstraintViolation> violations = inspect(CommandEnvelope.of(commandWithoutContext));
    assertEquals(1, violations.size());
}
Also used : Command(io.spine.core.Command) ConstraintViolation(io.spine.validate.ConstraintViolation) Test(org.junit.Test)

Example 38 with Command

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

the class ExecutorCommandSchedulerShould method not_schedule_command_with_same_id_twice.

@Test
public void not_schedule_command_with_same_id_twice() {
    final String id = newUuid();
    final Command expectedCmd = commandFactory.createBasedOnContext(createProjectMessage(id), context);
    final Command extraCmd = commandFactory.createBasedOnContext(addTask(id), context).toBuilder().setId(expectedCmd.getId()).build();
    scheduler.schedule(expectedCmd);
    scheduler.schedule(extraCmd);
    verify(scheduler, timeout(DELAY_MS + WAIT_FOR_PROPAGATION_MS)).post(any(Command.class));
    verify(scheduler, never()).post(extraCmd);
}
Also used : Command(io.spine.core.Command) Test(org.junit.Test)

Example 39 with Command

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

the class MultiTenantCommandBusShould method return_UnsupportedCommandException_when_there_is_neither_handler_nor_dispatcher.

@Test
public void return_UnsupportedCommandException_when_there_is_neither_handler_nor_dispatcher() {
    final Command command = addTask();
    commandBus.post(command, observer);
    checkCommandError(observer.firstResponse(), UNSUPPORTED_COMMAND, CommandValidationError.getDescriptor().getFullName(), command);
}
Also used : Command(io.spine.core.Command) Test(org.junit.Test)

Example 40 with Command

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

the class MultiTenantCommandBusShould method post_command_and_return_OK_response.

/*
     * Command processing tests
     ***************************/
@Test
public void post_command_and_return_OK_response() {
    commandBus.register(createProjectHandler);
    final Command command = createProject();
    commandBus.post(command, observer);
    checkResult(command);
}
Also used : Command(io.spine.core.Command) 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