Search in sources :

Example 1 with DecimalMinValidatorForNumber

use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber in project hibernate-validator by hibernate.

the class MinValidatorForNumberTest method testDecimalMin.

private void testDecimalMin(DecimalMin m, boolean inclusive) {
    AbstractDecimalMinValidator constraint = new DecimalMinValidatorForNumber();
    constraint.initialize(m);
    testNumberValidator(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForBigDecimal();
    constraint.initialize(m);
    testValidatorBigDecimal(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForBigInteger();
    constraint.initialize(m);
    testValidatorBigInteger(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForByte();
    constraint.initialize(m);
    testValidatorByte(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForShort();
    constraint.initialize(m);
    testValidatorShort(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForInteger();
    constraint.initialize(m);
    testValidatorInteger(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForLong();
    constraint.initialize(m);
    testValidatorLong(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForFloat();
    constraint.initialize(m);
    testValidatorFloat(constraint, inclusive, false);
    constraint = new DecimalMinValidatorForDouble();
    constraint.initialize(m);
    testValidatorDouble(constraint, inclusive, false);
}
Also used : DecimalMinValidatorForBigDecimal(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForBigDecimal) DecimalMinValidatorForInteger(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForInteger) DecimalMinValidatorForShort(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForShort) DecimalMinValidatorForByte(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForByte) DecimalMinValidatorForDouble(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForDouble) DecimalMinValidatorForFloat(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForFloat) DecimalMinValidatorForBigInteger(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForBigInteger) AbstractDecimalMinValidator(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.AbstractDecimalMinValidator) DecimalMinValidatorForNumber(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber) DecimalMinValidatorForLong(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForLong)

Example 2 with DecimalMinValidatorForNumber

use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber in project hibernate-validator by hibernate.

the class MinValidatorForNumberTest method testInitializeDecimalMinWithInvalidValue.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testInitializeDecimalMinWithInvalidValue() {
    ConstraintAnnotationDescriptor.Builder<DecimalMin> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMin.class);
    descriptorBuilder.setAttribute("value", "foobar");
    descriptorBuilder.setMessage("{validator.min}");
    DecimalMin m = descriptorBuilder.build().getAnnotation();
    DecimalMinValidatorForNumber constraint = new DecimalMinValidatorForNumber();
    constraint.initialize(m);
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMin(jakarta.validation.constraints.DecimalMin) DecimalMinValidatorForNumber(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber) Test(org.testng.annotations.Test)

Example 3 with DecimalMinValidatorForNumber

use of org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber in project hibernate-validator by hibernate.

the class MinValidatorForStringTest method testInitializeDecimalMaxWithInvalidValue.

@Test
public void testInitializeDecimalMaxWithInvalidValue() {
    ConstraintAnnotationDescriptor.Builder<DecimalMin> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMin.class);
    descriptorBuilder.setAttribute("value", "foobar");
    descriptorBuilder.setMessage("{validator.min}");
    DecimalMin m = descriptorBuilder.build().getAnnotation();
    DecimalMinValidatorForNumber constraint = new DecimalMinValidatorForNumber();
    try {
        constraint.initialize(m);
        fail();
    } catch (IllegalArgumentException e) {
    // success
    }
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMin(jakarta.validation.constraints.DecimalMin) DecimalMinValidatorForNumber(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber) Test(org.testng.annotations.Test)

Aggregations

DecimalMinValidatorForNumber (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForNumber)3 DecimalMin (jakarta.validation.constraints.DecimalMin)2 ConstraintAnnotationDescriptor (org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor)2 Test (org.testng.annotations.Test)2 AbstractDecimalMinValidator (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.AbstractDecimalMinValidator)1 DecimalMinValidatorForBigDecimal (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForBigDecimal)1 DecimalMinValidatorForBigInteger (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForBigInteger)1 DecimalMinValidatorForByte (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForByte)1 DecimalMinValidatorForDouble (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForDouble)1 DecimalMinValidatorForFloat (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForFloat)1 DecimalMinValidatorForInteger (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForInteger)1 DecimalMinValidatorForLong (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForLong)1 DecimalMinValidatorForShort (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForShort)1