use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnConstructor.
@Test
public void testIgnoreAnnotationsOnConstructor() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).constructor(String.class).ignoreAnnotations(true);
config.addMapping(mapping);
ConstructorDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForConstructor(String.class);
assertNull(descriptor);
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testGetConstrainedConstructors.
@Test
public void testGetConstrainedConstructors() {
BeanDescriptor descriptor = getBeanDescriptor(CustomerRepositoryExt.class);
Set<ConstructorDescriptor> constrainedConstructors = descriptor.getConstrainedConstructors();
assertThat(constrainedConstructors).isNotNull();
assertThat(getSignatures(constrainedConstructors)).containsOnly(Arrays.<Class<?>>asList(String.class), Arrays.<Class<?>>asList(String.class, Customer.class), Collections.<Class<?>>emptyList(), Arrays.<Class<?>>asList(LocalDate.class, LocalDate.class));
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method getSignatures.
private Set<List<Class<?>>> getSignatures(Set<ConstructorDescriptor> descriptors) {
Set<List<Class<?>>> signatures = newHashSet();
for (ConstructorDescriptor methodDescriptor : descriptors) {
List<Class<?>> parameterTypes = newArrayList();
for (ParameterDescriptor oneParameter : methodDescriptor.getParameterDescriptors()) {
parameterTypes.add(oneParameter.getElementClass());
}
signatures.add(parameterTypes);
}
return signatures;
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class BeanDescriptorTest method testGetConstraintsForConstructor.
@Test
public void testGetConstraintsForConstructor() {
BeanDescriptor descriptor = getBeanDescriptor(CustomerRepositoryExt.class);
ConstructorDescriptor constructorDescriptor = descriptor.getConstraintsForConstructor(String.class, Customer.class);
assertThat(constructorDescriptor).isNotNull();
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstructorDescriptorTest method testGetReturnValueDescriptor.
@Test
public void testGetReturnValueDescriptor() {
ConstructorDescriptor constructorDescriptor = getConstructorDescriptor(CustomerRepositoryExt.class, String.class);
ReturnValueDescriptor returnValueDescriptor = constructorDescriptor.getReturnValueDescriptor();
assertThat(returnValueDescriptor).isNotNull();
assertThat(returnValueDescriptor.getElementClass()).isEqualTo(CustomerRepositoryExt.class);
assertThat(returnValueDescriptor.hasConstraints()).isTrue();
assertThat(returnValueDescriptor.isCascaded()).isTrue();
Set<ConstraintDescriptor<?>> constraintDescriptors = returnValueDescriptor.getConstraintDescriptors();
assertThat(constraintDescriptors).hasSize(1);
ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
assertThat(descriptor.getAnnotation().annotationType()).isEqualTo(ValidB2BRepository.class);
}
Aggregations