use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.MaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForNumberTest method testMax.
private void testMax(Max m, boolean inclusive) {
AbstractMaxValidator constraint = new MaxValidatorForNumber();
constraint.initialize(m);
testNumberValidator(constraint, inclusive, true);
constraint = new MaxValidatorForBigDecimal();
constraint.initialize(m);
testValidatorBigDecimal(constraint, inclusive, true);
constraint = new MaxValidatorForBigInteger();
constraint.initialize(m);
testValidatorBigInteger(constraint, inclusive, true);
constraint = new MaxValidatorForByte();
constraint.initialize(m);
testValidatorByte(constraint, inclusive, true);
constraint = new MaxValidatorForShort();
constraint.initialize(m);
testValidatorShort(constraint, inclusive, true);
constraint = new MaxValidatorForInteger();
constraint.initialize(m);
testValidatorInteger(constraint, inclusive, true);
constraint = new MaxValidatorForLong();
constraint.initialize(m);
testValidatorLong(constraint, inclusive, true);
constraint = new MaxValidatorForFloat();
constraint.initialize(m);
testValidatorFloat(constraint, inclusive, true);
constraint = new MaxValidatorForDouble();
constraint.initialize(m);
testValidatorDouble(constraint, inclusive, true);
}
use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.MaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForNumberTest method testIsValidNumberForFloatingPointOrBigNumbersStoredAsNumber.
@Test
@TestForIssue(jiraKey = "HV-1699")
public void testIsValidNumberForFloatingPointOrBigNumbersStoredAsNumber() {
ConstraintAnnotationDescriptor.Builder<Max> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(Max.class);
descriptorBuilder.setAttribute("value", 1L);
Max m = descriptorBuilder.build().getAnnotation();
MaxValidatorForNumber validator = new MaxValidatorForNumber();
validator.initialize(m);
assertFalse(validator.isValid(1.01, null));
assertFalse(validator.isValid(1.01F, null));
assertFalse(validator.isValid(new BigDecimal("1.01"), null));
assertFalse(validator.isValid(new BigInteger("2"), null));
assertFalse(validator.isValid(Double.POSITIVE_INFINITY, null));
assertFalse(validator.isValid(Float.POSITIVE_INFINITY, null));
}
Aggregations