use of jakarta.validation.metadata.MethodDescriptor 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.MethodDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnMethodAndReturnValue.
@Test
public void testIgnoreAnnotationsOnMethodAndReturnValue() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).method("doSomething", String.class).ignoreAnnotations(true).returnValue().ignoreAnnotations(false);
config.addMapping(mapping);
MethodDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForMethod("doSomething", String.class);
assertTrue(descriptor.hasConstrainedReturnValue(), "Setting given for return value should take precedence");
}
use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnMethodAndCrossParameter.
@Test
public void testIgnoreAnnotationsOnMethodAndCrossParameter() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping = config.createConstraintMapping();
mapping.type(Doer.class).method("doAnotherThing", String.class).ignoreAnnotations(true).crossParameter().ignoreAnnotations(false);
config.addMapping(mapping);
MethodDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForMethod("doAnotherThing", String.class);
assertTrue(descriptor.hasConstrainedParameters(), "Setting given for cross-parameter should take precedence");
}
use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnMethodReturnValue.
@Test
public void testIgnoreAnnotationsOnMethodReturnValue() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).method("doSomething", String.class).returnValue().ignoreAnnotations(true);
config.addMapping(mapping);
MethodDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForMethod("doSomething", String.class);
assertFalse(descriptor.hasConstrainedReturnValue());
}
use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.
the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnMethodParameter.
@Test
public void testIgnoreAnnotationsOnMethodParameter() {
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type(Doer.class).method("doSomething", String.class).parameter(0).ignoreAnnotations(true);
config.addMapping(mapping);
MethodDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForMethod("doSomething", String.class);
assertFalse(descriptor.hasConstrainedParameters());
}
Aggregations