use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testGetConstrainedPropertiesForTypeWithClassLevelConstraint.
@Test
@TestForIssue(jiraKey = "HV-660")
public void testGetConstrainedPropertiesForTypeWithClassLevelConstraint() {
BeanDescriptor descriptor = getBeanDescriptor(ClassLevelConstrainedType.class);
Set<PropertyDescriptor> constrainedProperties = descriptor.getConstrainedProperties();
assertThat(constrainedProperties).isEmpty();
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class ConstraintDescriptorTest method testValidationAppliesTo.
@Test
public void testValidationAppliesTo() {
BeanDescriptor beanDescriptor = getBeanDescriptor(Bar.class);
Set<MethodDescriptor> methodDescriptors = beanDescriptor.getConstrainedMethods(MethodType.NON_GETTER);
assertEquals(methodDescriptors.size(), 1);
CrossParameterDescriptor crossParameterDescriptor = methodDescriptors.iterator().next().getCrossParameterDescriptor();
Set<ConstraintDescriptor<?>> constraintDescriptors = crossParameterDescriptor.getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1);
ConstraintDescriptor<?> constraintDescriptor = constraintDescriptors.iterator().next();
assertEquals(constraintDescriptor.getValidationAppliesTo(), ConstraintTarget.PARAMETERS, "wrong constraint targets");
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class ConstraintDescriptorTest method testBasicDescriptorAttributes.
@Test
public void testBasicDescriptorAttributes() {
BeanDescriptor beanDescriptor = getBeanDescriptor(Foo.class);
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty("fubar");
Set<ConstraintDescriptor<?>> constraintDescriptors = propertyDescriptor.getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1);
ConstraintDescriptor<?> constraintDescriptor = constraintDescriptors.iterator().next();
assertEquals(constraintDescriptor.getMessageTemplate(), "bar", "Wrong message");
Set<Class<?>> groups = newHashSet();
groups.add(SnafuGroup.class);
assertEquals(constraintDescriptor.getGroups(), groups, "Wrong groups");
Set<Class<?>> payloads = newHashSet();
payloads.add(Payload22.class);
assertEquals(constraintDescriptor.getPayload(), payloads, "Wrong payload");
assertNull(constraintDescriptor.getValidationAppliesTo(), "There is no validationAppliedTo attribute");
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testGetElementClass.
@Test
public void testGetElementClass() {
BeanDescriptor descriptor = getBeanDescriptor(CustomerRepository.class);
assertEquals(descriptor.getElementClass(), CustomerRepository.class);
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testIsTypeConstrainedForBeanConstrainedType.
@Test
public void testIsTypeConstrainedForBeanConstrainedType() {
BeanDescriptor descriptor = getBeanDescriptor(CustomerRepository.class);
assertTrue(descriptor.isBeanConstrained());
}
Aggregations