use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class IgnoreCrossParameterConstraintTest method testCrossParameterConstraintsAreIgnored.
@Test
@TestForIssue(jiraKey = "HV-734")
public void testCrossParameterConstraintsAreIgnored() {
Validator validator = getXmlConfiguredValidator("ignore-annotations-for-cross-parameter-constraints.xml");
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(this.getClass());
// check that the test constructor has no cross parameter constraint
ConstructorDescriptor constructorDescriptor = beanDescriptor.getConstraintsForConstructor(String.class, String.class);
CrossParameterDescriptor crossParameterDescriptor = constructorDescriptor.getCrossParameterDescriptor();
assertFalse(crossParameterDescriptor.hasConstraints(), "There should be no cross parameter constraints.");
// check that the test method has no cross parameter constraint
MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod("snafu", String.class, String.class);
crossParameterDescriptor = methodDescriptor.getCrossParameterDescriptor();
assertFalse(crossParameterDescriptor.hasConstraints(), "There should be no cross parameter constraints.");
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnConstructorParameter.
@Test
public void testIgnoreAnnotationsOnConstructorParameter() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).constructor(String.class).parameter(0).ignoreAnnotations(true);
config.addMapping(mapping);
ConstructorDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForConstructor(String.class);
assertFalse(descriptor.hasConstrainedParameters());
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnConstructorCrossParameter.
@Test
public void testIgnoreAnnotationsOnConstructorCrossParameter() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).constructor(String.class, String.class).crossParameter().ignoreAnnotations(true);
config.addMapping(mapping);
ConstructorDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForConstructor(String.class, String.class);
assertNull(descriptor);
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnConstructorAndReturnValue.
@Test
public void testIgnoreAnnotationsOnConstructorAndReturnValue() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).constructor(String.class).ignoreAnnotations(true).returnValue().ignoreAnnotations(false);
config.addMapping(mapping);
ConstructorDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForConstructor(String.class);
assertTrue(descriptor.hasConstrainedReturnValue(), "Setting given for return value should take precedence");
}
use of jakarta.validation.metadata.ConstructorDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnTypeAndConstructor.
@Test
public void testIgnoreAnnotationsOnTypeAndConstructor() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).ignoreAnnotations(true).constructor(String.class).ignoreAnnotations(false);
config.addMapping(mapping);
ConstructorDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForConstructor(String.class);
assertTrue(descriptor.hasConstrainedParameters());
assertTrue(descriptor.hasConstrainedReturnValue());
}
Aggregations