use of jakarta.validation.metadata.ElementDescriptor in project hibernate-validator by hibernate.
the class ElementDescriptorTest method testElementDescriptorForProperty.
@Test
@TestForIssue(jiraKey = "HV-95")
public void testElementDescriptorForProperty() {
ElementDescriptor elementDescriptor = ValidatorUtil.getPropertyDescriptor(Order.class, "orderNumber");
Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
assertTrue(constraintDescriptors.size() == 1, "There should be a descriptor");
}
use of jakarta.validation.metadata.ElementDescriptor in project hibernate-validator by hibernate.
the class ElementDescriptorTest method testGetTypeForConstrainedProperty.
@Test
public void testGetTypeForConstrainedProperty() {
ElementDescriptor elementDescriptor = ValidatorUtil.getPropertyDescriptor(Order.class, "orderNumber");
assertEquals(elementDescriptor.getElementClass(), Integer.class, "Wrong type.");
}
use of jakarta.validation.metadata.ElementDescriptor in project hibernate-validator by hibernate.
the class ElementDescriptorTest method testElementDescriptorImmutable.
@Test
@TestForIssue(jiraKey = "HV-95")
public void testElementDescriptorImmutable() {
ElementDescriptor elementDescriptor = ValidatorUtil.getPropertyDescriptor(Order.class, "orderNumber");
Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
try {
constraintDescriptors.add(null);
fail("Set should be immutable");
} catch (UnsupportedOperationException e) {
// success
}
try {
constraintDescriptors.remove(constraintDescriptors.iterator().next());
fail("Set should be immutable");
} catch (UnsupportedOperationException e) {
}
}
Aggregations