/** * This class kicks the validate call back up through the RAVE api. This is because this particular validator may * not know how to handle the input class. Using the Rave.validate api allows Rave to correctly route the object * to the appropriate validator. * * @param clazz the class to validate this object as. * @param obj the object to validate * @return A list of {@link RaveError}s. */ @Nullable protected final List<RaveError> reEvaluateAsSuperType( Class<?> clazz, Object obj) { try { Rave.getInstance().validateAs(obj, clazz); } catch (RaveException e) { return e.errors; } return null; }
@Test(expected = IllegalArgumentException.class) public void validateAs_whenClazzTypeDoesntMatchObjectType_shouldFailWithException() throws RaveException { Rave.getInstance().validateAs(new Object(), String.class); }
@Test(expected = UnsupportedObjectException.class) public void validateAs_whenTypeIsNotSupported_shouldFailWithRaveUnsupportedException() throws RaveException { Rave.getInstance().validateAs(new Object(), Object.class); }