PositiveDimensionValidator implements ConstraintValidator<PositiveDimensions, Dimension2D> { @Override public boolean isValid(Dimension2D value, ConstraintValidatorContext context) { if (value != null) { return value.getWidth() > 0 && value.getHeight() > 0; } return true; }  @Override void initialize(PositiveDimensions constraintAnnotation); @Override boolean isValid(Dimension2D value, ConstraintValidatorContext context);  }
@Test public void testNull() { assertTrue(victim.isValid(null, null)); }
@Test public void positive() { assertTrue(victim.isValid(new Dimension(10, 20), null)); }
@Test public void negative() { assertFalse(victim.isValid(new Dimension(-10, -20), null)); }
@Test public void negativeWidth() { assertFalse(victim.isValid(new Dimension(-10, 20), null)); }
@Test public void negativeHeight() { assertFalse(victim.isValid(new Dimension(10, -20), null)); }