use of io.spine.base.Error in project core-java by SpineEventEngine.
the class EventValidatorShould method validate_event_messages.
@Test
public void validate_event_messages() {
final MessageValidator messageValidator = mock(MessageValidator.class);
when(messageValidator.validate(any(Message.class))).thenReturn(newArrayList(ConstraintViolation.getDefaultInstance(), ConstraintViolation.getDefaultInstance()));
final Event event = eventFactory.createEvent(Sample.messageOfType(ProjectCreated.class));
final EventValidator eventValidator = new EventValidator(messageValidator);
final Optional<MessageInvalid> error = eventValidator.validate(EventEnvelope.of(event));
assertTrue(error.isPresent());
final Error actualError = error.get().asError();
assertEquals(EventValidationError.getDescriptor().getFullName(), actualError.getType());
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class RejectionBusShould method report_dead_messages.
@Test
public void report_dead_messages() {
final MemoizingObserver<Ack> observer = memoizingObserver();
rejectionBus.post(missingOwnerRejection(), observer);
assertTrue(observer.isCompleted());
final Ack result = observer.firstResponse();
assertNotNull(result);
assertEquals(ERROR, result.getStatus().getStatusCase());
final Error error = result.getStatus().getError();
assertEquals(UnhandledRejectionException.class.getCanonicalName(), error.getType());
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class StorageShould method set_error_command_status.
// We get right after we update status.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void set_error_command_status() {
givenNewRecord();
final Error error = newError();
repository.updateStatus(id, error);
final CommandRecord actual = read(id).get();
assertEquals(ERROR, actual.getStatus().getCode());
assertEquals(error, actual.getStatus().getError());
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_error_and_generate_ID_if_needed.
@Test
public void store_command_with_error_and_generate_ID_if_needed() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final Command command = factory.createCommand(createProjectMessage());
final Error error = newError();
repository.store(command, error);
final List<CommandRecord> records = Lists.newArrayList(repository.iterator(ERROR));
assertEquals(1, records.size());
final String commandIdStr = Identifier.toString(records.get(0).getCommandId());
assertFalse(commandIdStr.isEmpty());
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_error.
// We get right after we store.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void store_command_with_error() {
final Command command = Given.ACommand.createProject();
final CommandId commandId = command.getId();
final Error error = newError();
repository.store(command, error);
final CommandRecord record = read(commandId).get();
checkRecord(record, command, ERROR);
assertEquals(error, record.getStatus().getError());
}
Aggregations