use of io.spine.base.Error in project core-java by SpineEventEngine.
the class MetadataConverterShould method return_error_extracted_form_metadata.
@Test
public void return_error_extracted_form_metadata() {
final Error expectedError = Error.getDefaultInstance();
final Metadata metadata = MetadataConverter.toMetadata(expectedError);
assertEquals(expectedError, MetadataConverter.toError(metadata).get());
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class MetadataConverterShould method return_metadata_containing_error.
// A part of the test.
@SuppressWarnings("ConstantConditions")
@Test
public void return_metadata_containing_error() throws InvalidProtocolBufferException {
final Error error = Error.getDefaultInstance();
final Metadata metadata = MetadataConverter.toMetadata(error);
final byte[] bytes = metadata.get(MetadataConverter.KEY);
assertEquals(error, Error.parseFrom(bytes));
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class CommandStoreShould method set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed.
@Test
public void set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed() {
final List<Command> commands = newArrayList(createProject(), addTask(), startProject());
final Duration delay = fromMinutes(5);
// time to post passed
final Timestamp schedulingTime = TimeTests.Past.minutesAgo(10);
storeAsScheduled(commands, delay, schedulingTime);
commandBus.rescheduleCommands();
for (Command cmd : commands) {
final CommandEnvelope envelope = CommandEnvelope.of(cmd);
final Message msg = envelope.getMessage();
final CommandId id = envelope.getCommandId();
// Check the expired status error was set.
final ProcessingStatus status = getProcessingStatus(envelope);
// Check that the logging was called.
verify(log).errorExpiredCommand(msg, id);
final Error expected = CommandExpiredException.commandExpiredError(msg);
assertEquals(expected, status.getError());
}
}
use of io.spine.base.Error in project core-java by SpineEventEngine.
the class AbstractCommandBusTestSuite method checkCommandError.
static <E extends CommandException> void checkCommandError(Throwable throwable, CommandValidationError validationError, Class<E> exceptionClass, Command cmd) {
final Throwable cause = throwable.getCause();
assertEquals(exceptionClass, cause.getClass());
@SuppressWarnings("unchecked") final E exception = (E) cause;
assertEquals(cmd, exception.getCommand());
final Error error = exception.getError();
assertEquals(CommandValidationError.getDescriptor().getFullName(), error.getType());
assertEquals(validationError.getNumber(), error.getCode());
assertFalse(error.getMessage().isEmpty());
if (validationError == INVALID_COMMAND) {
assertFalse(error.getValidationError().getConstraintViolationList().isEmpty());
}
}
Aggregations