Search in sources :

Example 1 with DecimalMaxValidatorForCharSequence

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

the class MaxValidatorForStringTest method testIsValidDecimalMaxExclusive.

@Test
@TestForIssue(jiraKey = "HV-256")
public void testIsValidDecimalMaxExclusive() {
    boolean inclusive = false;
    ConstraintAnnotationDescriptor.Builder<DecimalMax> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMax.class);
    descriptorBuilder.setAttribute("value", "15.0E0");
    descriptorBuilder.setAttribute("inclusive", inclusive);
    descriptorBuilder.setMessage("{validator.max}");
    DecimalMax m = descriptorBuilder.build().getAnnotation();
    DecimalMaxValidatorForCharSequence constraint = new DecimalMaxValidatorForCharSequence();
    constraint.initialize(m);
    testMaxValidator(constraint, inclusive);
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMax(jakarta.validation.constraints.DecimalMax) DecimalMaxValidatorForCharSequence(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForCharSequence) Test(org.testng.annotations.Test) TestForIssue(org.hibernate.validator.testutil.TestForIssue)

Example 2 with DecimalMaxValidatorForCharSequence

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

the class MaxValidatorForStringTest method testIsValidDecimalMax.

@Test
public void testIsValidDecimalMax() {
    ConstraintAnnotationDescriptor.Builder<DecimalMax> descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>(DecimalMax.class);
    descriptorBuilder.setAttribute("value", "15.0E0");
    descriptorBuilder.setMessage("{validator.max}");
    DecimalMax m = descriptorBuilder.build().getAnnotation();
    DecimalMaxValidatorForCharSequence constraint = new DecimalMaxValidatorForCharSequence();
    constraint.initialize(m);
    testMaxValidator(constraint, true);
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) DecimalMax(jakarta.validation.constraints.DecimalMax) DecimalMaxValidatorForCharSequence(org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForCharSequence) Test(org.testng.annotations.Test)

Aggregations

DecimalMax (jakarta.validation.constraints.DecimalMax)2 DecimalMaxValidatorForCharSequence (org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMaxValidatorForCharSequence)2 ConstraintAnnotationDescriptor (org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor)2 Test (org.testng.annotations.Test)2 TestForIssue (org.hibernate.validator.testutil.TestForIssue)1