use of jakarta.validation.metadata.MethodDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class MethodValidationTest method testVarargsMethodParameter.
@Test
@SpecAssertions({ @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "a"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "b"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "c") })
public void testVarargsMethodParameter() throws Exception {
MethodDescriptor descriptor = TestUtil.getMethodDescriptor(CustomerRepository.class, "addCustomers", Customer[].class);
assertNotNull(descriptor, "the specified method should be configured in xml");
assertTrue(descriptor.hasConstrainedParameters());
}
use of jakarta.validation.metadata.MethodDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class MethodValidationTest method testCascadingOnReturnValueAndParameter.
@Test
@SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "i")
public void testCascadingOnReturnValueAndParameter() throws Exception {
MethodDescriptor descriptor = TestUtil.getMethodDescriptor(CustomerRepository.class, "findByExample", Customer.class);
assertNotNull(descriptor, "the specified method should be configured in xml");
ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
assertTrue(returnValueDescriptor.isCascaded(), "<valid/> is used to configure cascading");
List<ParameterDescriptor> parameterDescriptors = descriptor.getParameterDescriptors();
assertTrue(parameterDescriptors.size() == 1);
ParameterDescriptor parameterDescriptor = parameterDescriptors.get(0);
assertTrue(parameterDescriptor.isCascaded(), "<valid/> is used to configure cascading");
}
use of jakarta.validation.metadata.MethodDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class MethodValidationTest method testMethodCrossParameterConstraint.
@Test
@SpecAssertions({ @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "c"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "g"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "k") })
public void testMethodCrossParameterConstraint() throws Exception {
MethodDescriptor descriptor = TestUtil.getMethodDescriptor(CustomerRepository.class, "notifyCustomer", Customer.class, String.class);
assertNotNull(descriptor, "the specified method should be configured in xml");
CrossParameterDescriptor crossParameterDescriptor = descriptor.getCrossParameterDescriptor();
assertTrue(crossParameterDescriptor.hasConstraints());
Set<ConstraintDescriptor<?>> constraintDescriptors = crossParameterDescriptor.getConstraintDescriptors();
assertTrue(constraintDescriptors.size() == 1);
ConstraintDescriptor<?> constraintDescriptor = constraintDescriptors.iterator().next();
assertEquals(constraintDescriptor.getAnnotation().annotationType(), CrossRepositoryConstraint.class, "Unexpected constraint type");
}
use of jakarta.validation.metadata.MethodDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class CascadedValidationTest method testValidaAnnotationIsApplied.
@Test
@SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_METHODLEVELOVERRIDING, id = "o")
public void testValidaAnnotationIsApplied() throws Exception {
MethodDescriptor descriptor = TestUtil.getMethodDescriptor(Cascaded.class, "cascade", String.class);
assertNotNull(descriptor, "the specified method should be configured in xml");
ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
assertTrue(returnValueDescriptor.isCascaded(), "Cascaded validation should be applied");
ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get(0);
assertTrue(parameterDescriptor.isCascaded(), "Cascaded validation should be applied");
}
use of jakarta.validation.metadata.MethodDescriptor in project beanvalidation-tck by eclipse-ee4j.
the class ExecutableDescriptorIgnoresValidatedExecutableXmlSettingsTest method testMethodDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEInXml.
@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "h")
public void testMethodDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEInXml() {
assertEquals(Validation.byDefaultProvider().configure().getBootstrapConfiguration().getDefaultValidatedExecutableTypes(), Collections.emptySet());
MethodDescriptor descriptor = getMethodDescriptor(StockItem.class, "setName", String.class);
assertNotNull(descriptor);
assertEquals(descriptor.getName(), "setName");
assertEquals(descriptor.getParameterDescriptors().get(0).getConstraintDescriptors().size(), 1);
}
Aggregations