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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations