Search in sources :

Example 1 with CommandValidationError

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());
    }
}
Also used : Error(io.spine.base.Error) CommandValidationError(io.spine.base.CommandValidationError)

Aggregations

CommandValidationError (io.spine.base.CommandValidationError)1 Error (io.spine.base.Error)1