Search in sources :

Example 16 with ConstructorDescriptor

use of jakarta.validation.metadata.ConstructorDescriptor in project beanvalidation-tck by eclipse-ee4j.

the class ConstructorValidationTest method testXmlConfiguredConstructors.

@Test
@SpecAssertions({ @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_CONSTRUCTORLEVELOVERRIDING, id = "a"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_CONSTRUCTORLEVELOVERRIDING, id = "c"), @SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_CONSTRUCTORLEVELOVERRIDING, id = "e") })
public void testXmlConfiguredConstructors() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(CustomerRepository.class);
    assertNotNull(descriptor, "the specified constructor should be configured in xml");
    assertTrue(descriptor.hasConstrainedReturnValue());
    descriptor = TestUtil.getConstructorDescriptor(CustomerRepository.class, String.class);
    assertNotNull(descriptor, "the specified constructor should be configured in xml");
    assertTrue(descriptor.hasConstrainedParameters());
    descriptor = TestUtil.getConstructorDescriptor(CustomerRepository.class, CustomerRepository.class);
    assertNotNull(descriptor, "the specified constructor should be configured in xml");
    assertTrue(descriptor.hasConstrainedParameters());
}
Also used : ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test)

Example 17 with ConstructorDescriptor

use of jakarta.validation.metadata.ConstructorDescriptor in project beanvalidation-tck by eclipse-ee4j.

the class DisabledCascadedValidationTest method testValidAnnotationIsIgnored.

@Test
@SpecAssertion(section = Sections.XML_MAPPING_CONSTRAINTDECLARATIONINXML_CONSTRUCTORLEVELOVERRIDING, id = "n")
public void testValidAnnotationIsIgnored() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(Cascaded.class, String.class);
    assertNotNull(descriptor, "the specified constructor should be configured in xml");
    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertFalse(returnValueDescriptor.isCascaded(), "Cascaded validation should disabled");
    ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get(0);
    assertFalse(parameterDescriptor.isCascaded(), "Cascaded validation should disabled");
}
Also used : ReturnValueDescriptor(jakarta.validation.metadata.ReturnValueDescriptor) ParameterDescriptor(jakarta.validation.metadata.ParameterDescriptor) ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 18 with ConstructorDescriptor

use of jakarta.validation.metadata.ConstructorDescriptor in project beanvalidation-tck by eclipse-ee4j.

the class ExecutableDescriptorIgnoresValidatedExecutableAnnotationSettingsTest method testConstructorDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEOnTypeLevel.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "h")
public void testConstructorDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEOnTypeLevel() {
    ConstructorDescriptor descriptor = getConstructorDescriptor(OrderLine.class, String.class);
    assertNotNull(descriptor);
    assertEquals(descriptor.getName(), "OrderLine");
    assertEquals(descriptor.getParameterDescriptors().get(0).getConstraintDescriptors().size(), 1);
}
Also used : TestUtil.getConstructorDescriptor(org.hibernate.beanvalidation.tck.util.TestUtil.getConstructorDescriptor) ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 19 with ConstructorDescriptor

use of jakarta.validation.metadata.ConstructorDescriptor in project beanvalidation-tck by eclipse-ee4j.

the class ExecutableDescriptorIgnoresValidatedExecutableXmlSettingsTest method testConstructorDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEInXml.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "h")
public void testConstructorDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEInXml() {
    assertEquals(Validation.byDefaultProvider().configure().getBootstrapConfiguration().getDefaultValidatedExecutableTypes(), Collections.emptySet());
    ConstructorDescriptor descriptor = getConstructorDescriptor(StockItem.class, String.class);
    assertNotNull(descriptor);
    assertEquals(descriptor.getName(), "StockItem");
    assertEquals(descriptor.getParameterDescriptors().get(0).getConstraintDescriptors().size(), 1);
}
Also used : TestUtil.getConstructorDescriptor(org.hibernate.beanvalidation.tck.util.TestUtil.getConstructorDescriptor) ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 20 with ConstructorDescriptor

use of jakarta.validation.metadata.ConstructorDescriptor in project beanvalidation-tck by eclipse-ee4j.

the class ExecutableDescriptorTest method testGetConstraintsForConstructor.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "g")
public void testGetConstraintsForConstructor() {
    ConstructorDescriptor parameterConstrainedDescriptor = Executables.parameterConstrainedConstructor();
    assertTrue(parameterConstrainedDescriptor.getConstraintDescriptors().isEmpty(), "Should have no constraints");
    ConstructorDescriptor returnValueConstrainedDescriptor = Executables.returnValueConstrainedConstructor();
    assertTrue(returnValueConstrainedDescriptor.getConstraintDescriptors().isEmpty(), "Should have no constraints");
    ConstructorDescriptor crossParameterConstrainedDescriptor = Executables.crossParameterConstrainedConstructor();
    assertTrue(crossParameterConstrainedDescriptor.getConstraintDescriptors().isEmpty(), "Should have no constraints");
}
Also used : ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Aggregations

ConstructorDescriptor (jakarta.validation.metadata.ConstructorDescriptor)64 Test (org.testng.annotations.Test)59 AbstractTCKTest (org.hibernate.beanvalidation.tck.tests.AbstractTCKTest)43 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)38 ParameterDescriptor (jakarta.validation.metadata.ParameterDescriptor)12 ReturnValueDescriptor (jakarta.validation.metadata.ReturnValueDescriptor)11 BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)10 CrossParameterDescriptor (jakarta.validation.metadata.CrossParameterDescriptor)10 ConstraintMapping (org.hibernate.validator.cfg.ConstraintMapping)8 SpecAssertions (org.jboss.test.audit.annotations.SpecAssertions)5 ConstraintDescriptor (jakarta.validation.metadata.ConstraintDescriptor)4 MethodDescriptor (jakarta.validation.metadata.MethodDescriptor)4 List (java.util.List)3 TestUtil.getConstructorDescriptor (org.hibernate.beanvalidation.tck.util.TestUtil.getConstructorDescriptor)3 ValidatorUtil.getBeanDescriptor (org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor)3 ValidatorUtil.getConstructorDescriptor (org.hibernate.validator.testutils.ValidatorUtil.getConstructorDescriptor)3 ConstraintValidator (jakarta.validation.ConstraintValidator)2 Validator (jakarta.validation.Validator)2 GroupConversionDescriptor (jakarta.validation.metadata.GroupConversionDescriptor)2 ArrayList (java.util.ArrayList)2