use of io.spine.base.CommandValidationError 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