use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testIsTypeConstrainedForConstructorParameterConstrainedType.
@Test
public void testIsTypeConstrainedForConstructorParameterConstrainedType() {
BeanDescriptor descriptor = getBeanDescriptor(ConstructorParameterConstrainedType.class);
assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
assertTrue(descriptor.getConstrainedMethods(MethodType.NON_GETTER, MethodType.GETTER).isEmpty(), "The entity should have no constrained methods");
assertTrue(descriptor.getConstrainedConstructors().size() == 1, "The entity should have a constrained constructor");
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testIsTypeConstrainedForReturnValueConstrainedType.
@Test
public void testIsTypeConstrainedForReturnValueConstrainedType() {
BeanDescriptor descriptor = getBeanDescriptor(ReturnValueConstrainedType.class);
assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
assertFalse(descriptor.getConstrainedMethods(MethodType.NON_GETTER).isEmpty(), "The entity should have constrained methods");
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testGetConstraintsForMethodFromBaseType.
// A method descriptor can be retrieved by specifying a method from a base
// type (qax() is not defined on CustomerRepositoryExt, but only on
// CustomerRepository).
@Test
public void testGetConstraintsForMethodFromBaseType() throws Exception {
BeanDescriptor descriptor = getBeanDescriptor(CustomerRepositoryExt.class);
MethodDescriptor methodDescriptor = descriptor.getConstraintsForMethod("qax", Integer.class);
assertNotNull(methodDescriptor);
}
use of jakarta.validation.metadata.BeanDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testIsTypeConstrainedForDerivedConstrainedType.
@Test
public void testIsTypeConstrainedForDerivedConstrainedType() {
BeanDescriptor descriptor = getBeanDescriptor(DerivedConstrainedType.class);
assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
assertFalse(descriptor.getConstrainedMethods(MethodType.NON_GETTER).isEmpty(), "The entity should have constrained methods");
}
use of jakarta.validation.metadata.BeanDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class DuplicateConfigurationTest method testXmlConfiguredConstraintExposesCorrespondingAnnotationViaMetadata.
@Test
@SpecAssertion(section = Sections.XML_MAPPING, id = "a")
public void testXmlConfiguredConstraintExposesCorrespondingAnnotationViaMetadata() {
Configuration<?> config = TestUtil.getConfigurationUnderTest();
config.addMapping(TestUtil.getInputStreamForPath(packageName + mappingFile1));
Validator validator = config.buildValidatorFactory().getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(User.class);
Set<ConstraintDescriptor<?>> constraintDescriptors = beanDescriptor.getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1, "There should be one class level constraint defined in xml");
ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
assertTrue(descriptor.getAnnotation() instanceof ConsistentUserInformation);
constraintDescriptors = beanDescriptor.getConstraintsForProperty("lastname").getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1, "There should be one constraint defined in xml for 'lastname'");
descriptor = constraintDescriptors.iterator().next();
assertTrue(descriptor.getAnnotation() instanceof Pattern);
}
Aggregations