use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForNumberTest method testDecimalMax.
private void testDecimalMax(DecimalMax m, boolean inclusive) {
AbstractDecimalMaxValidator constraint = new DecimalMaxValidatorForNumber();
constraint.initialize(m);
testNumberValidator(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForBigDecimal();
constraint.initialize(m);
testValidatorBigDecimal(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForBigInteger();
constraint.initialize(m);
testValidatorBigInteger(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForByte();
constraint.initialize(m);
testValidatorByte(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForShort();
constraint.initialize(m);
testValidatorShort(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForInteger();
constraint.initialize(m);
testValidatorInteger(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForLong();
constraint.initialize(m);
testValidatorLong(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForFloat();
constraint.initialize(m);
testValidatorFloat(constraint, inclusive, true);
constraint = new DecimalMaxValidatorForDouble();
constraint.initialize(m);
testValidatorDouble(constraint, inclusive, true);
}
use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForNumberTest method testInitializeDecimalMaxWithInvalidValue.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInitializeDecimalMaxWithInvalidValue() {
ConstraintAnnotationDescriptor.Builder<DecimalMax> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMax.class);
descriptorBuilder.setAttribute("value", "foobar");
descriptorBuilder.setMessage("{validator.max}");
DecimalMax m = descriptorBuilder.build().getAnnotation();
DecimalMaxValidatorForNumber constraint = new DecimalMaxValidatorForNumber();
constraint.initialize(m);
}
use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForStringTest method testInitializeDecimalMaxWithInvalidValue.
@Test
public void testInitializeDecimalMaxWithInvalidValue() {
ConstraintAnnotationDescriptor.Builder<DecimalMax> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMax.class);
descriptorBuilder.setAttribute("value", "foobar");
descriptorBuilder.setMessage("{validator.max}");
DecimalMax m = descriptorBuilder.build().getAnnotation();
DecimalMaxValidatorForNumber constraint = new DecimalMaxValidatorForNumber();
try {
constraint.initialize(m);
fail();
} catch (IllegalArgumentException e) {
// success
}
}
use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForNumber in project hibernate-validator by hibernate.
the class MaxValidatorForNumberTest method testIsValidDecimalMax1.
@Test
public void testIsValidDecimalMax1() {
ConstraintAnnotationDescriptor.Builder<DecimalMax> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMax.class);
descriptorBuilder.setAttribute("value", Integer.toString(Integer.MAX_VALUE - 1));
DecimalMax m = descriptorBuilder.build().getAnnotation();
DecimalMaxValidatorForNumber constraint = new DecimalMaxValidatorForNumber();
constraint.initialize(m);
assertFalse(constraint.isValid(Double.POSITIVE_INFINITY, null));
}
Aggregations