public static boolean validate(final Object target, final Object value, final String fieldName) { if (value == null) { return true; } Object valueToCompare; try { valueToCompare = BeanUtil.pojo.getProperty(target, fieldName); } catch (BeanException bex) { throw new VtorException("Invalid value: " + fieldName, bex); } if (valueToCompare == null) { return false; } return value.equals(valueToCompare); }
@Test void testConstructor3() { //given String message = "test"; RuntimeException cause = new RuntimeException(); //when VtorException vtorException = new VtorException(message, cause); //then assertEquals(message+"; <--- java.lang.RuntimeException", vtorException.getMessage()); assertEquals(cause, vtorException.getCause()); } }
@Test void testConstructor1() { //given RuntimeException cause = new RuntimeException("test"); //when VtorException vtorException = new VtorException(cause); //then assertEquals(cause, vtorException.getCause()); }
@Test void testConstructor2() { //given String message = "test"; //when VtorException vtorException = new VtorException(message); //then assertEquals(message, vtorException.getMessage()); }
public static boolean validate(final Object target, final Object value, final String fieldName) { if (value == null) { return true; } Object valueToCompare; try { valueToCompare = BeanUtil.declared.getProperty(target, fieldName); } catch (BeanException bex) { throw new VtorException("Invalid value: " + fieldName, bex); } if (valueToCompare == null) { return false; } return value.equals(valueToCompare); } }
vc = newConstraint(constraintClass, targetType); } catch (Exception ex) { throw new VtorException("Invalid constraint: " + constraintClass.getClass().getName(), ex);
public static boolean validate(Object target, Object value, String fieldName) { if (value == null) { return true; } Object valueToCompare; try { valueToCompare = BeanUtil.getProperty(target, fieldName); } catch (BeanException bex) { throw new VtorException("Unable to read value to compare: " + fieldName, bex); } if (valueToCompare == null) { return false; } return value.equals(valueToCompare); }
public static boolean validate(Object target, Object value, String fieldName) { if (value == null) { return true; } Object valueToCompare; try { valueToCompare = BeanUtil.getDeclaredProperty(target, fieldName); } catch (BeanException bex) { throw new VtorException("Unable to read value to compare: " + fieldName, bex); } if (valueToCompare == null) { return false; } return value.equals(valueToCompare); } }
/** * Collect annotations for some target. */ @SuppressWarnings({"unchecked"}) protected void collectAnnotationChecks(List<Check> annChecks, Class targetType, String targetName, Annotation[] annotations) { for (Annotation annotation : annotations) { Constraint c = annotation.annotationType().getAnnotation(Constraint.class); if (c == null) { continue; } Class<? extends ValidationConstraint> constraintClass = c.value(); ValidationConstraint vc; try { vc = newConstraint(constraintClass, targetType); } catch (Exception ex) { throw new VtorException("Unable to create constraint: " + constraintClass.getClass().getName(), ex); } vc.configure(annotation); Check check = new Check(targetName, vc); copyDefaultCheckProperties(check, annotation); annChecks.add(check); } }