use of io.spine.base.Command in project core-java by SpineEventEngine.
the class SingleTenantCommandBusShould method propagate_failures_to_failure_bus.
@Test
public void propagate_failures_to_failure_bus() {
final FaultyHandler faultyHandler = new FaultyHandler(eventBus);
commandBus.register(faultyHandler);
final Command addTaskCommand = clearTenantId(addTask());
commandBus.post(addTaskCommand, StreamObservers.<Response>noOpObserver());
final InvalidProjectName failureThrowable = faultyHandler.getThrowable();
final Failure expectedFailure = failureThrowable.toFailure(addTaskCommand);
verify(failureBus).post(eq(expectedFailure), ArgumentMatchers.<StreamObserver<Response>>any());
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class ValidatorShould method validate_command_and_return_violations_if_message_is_NOT_valid.
@Test
public void validate_command_and_return_violations_if_message_is_NOT_valid() {
final Any invalidMessagePacked = AnyPacker.pack(CreateProject.getDefaultInstance());
final Command commandWithEmptyMessage = Command.newBuilder().setId(generateId()).setMessage(invalidMessagePacked).setContext(createCommandContext()).build();
final List<ConstraintViolation> violations = validator.validate(CommandEnvelope.of(commandWithEmptyMessage));
assertEquals(3, violations.size());
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class CommandTestShould method stores_command_after_creation.
// This test verifies that Optionals
@SuppressWarnings("OptionalGetWithoutIsPresent")
// are initialized.
@Test
public void stores_command_after_creation() {
final StringValue commandMessage = newUuidValue();
final Command command = commandTest.createCommand(commandMessage);
assertEquals(commandMessage, commandTest.commandMessage().get());
assertEquals(command.getContext(), commandTest.commandContext().get());
assertEquals(command, commandTest.command().get());
}
use of io.spine.base.Command in project core-java by SpineEventEngine.
the class CommandTestShould method create_command_with_custom_Timestamp.
@Test
public void create_command_with_custom_Timestamp() {
final StringValue commandMessage = newUuidValue();
final Timestamp timestamp = TimeTests.Past.minutesAgo(5);
final Command command = commandTest.createCommand(commandMessage, timestamp);
assertEquals(timestamp, command.getContext().getActorContext().getTimestamp());
}
Aggregations