PositiveNumberValidator implements ConstraintValidator<Positive, Number> { @Override public boolean isValid(Number value, ConstraintValidatorContext constraintValidatorContext) { if (value == null) { return true; } if (value instanceof BigDecimal) { return ((BigDecimal) value).compareTo(BigDecimal.ZERO) == 1; } else if (value instanceof BigInteger) { return ((BigInteger) value).compareTo(BigInteger.ZERO) == 1; } else { return value.floatValue() > 0; } }  @Override void initialize(Positive minValue); @Override boolean isValid(Number value, ConstraintValidatorContext constraintValidatorContext);  }
@Test public void testNull() { assertTrue(victim.isValid(null, null)); }
@Test public void testValidBigDecimal() { assertTrue(victim.isValid(BigDecimal.ONE, null)); }
@Test public void testInvalidBigDecimal() { assertFalse(victim.isValid(BigDecimal.ZERO, null)); }
@Test public void testValidBigInteger() { assertTrue(victim.isValid(BigInteger.ONE, null)); }
@Test public void testInvalidBigInteger() { assertFalse(victim.isValid(BigInteger.ZERO, null)); }
@Test public void testValidLong() { assertTrue(victim.isValid(1l, null)); }
@Test public void testInvalidLong() { assertFalse(victim.isValid(-1l, null)); }
@Test public void testValiFloat() { assertTrue(victim.isValid(0.3f, null)); }
@Test public void testInvalidFloat() { assertFalse(victim.isValid(-0.1f, null)); }
@Test public void testValiDouble() { assertTrue(victim.isValid(0.3d, null)); }
@Test public void testInvaliddouble() { assertFalse(victim.isValid(-0.1d, null)); }