Search in sources :

Example 6 with MethodDescriptor

use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.

the class ConstraintMappingWithAnnotationProcessingOptionsTest method testIgnoreAnnotationsOnMethod.

@Test
public void testIgnoreAnnotationsOnMethod() {
    ConstraintMapping mapping = config.createConstraintMapping();
    mapping.type(Doer.class).method("doSomething", String.class).ignoreAnnotations(true);
    config.addMapping(mapping);
    MethodDescriptor descriptor = config.buildValidatorFactory().getValidator().getConstraintsForClass(Doer.class).getConstraintsForMethod("doSomething", String.class);
    assertNull(descriptor);
}
Also used : ConstraintMapping(org.hibernate.validator.cfg.ConstraintMapping) MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) Test(org.testng.annotations.Test)

Example 7 with MethodDescriptor

use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.

the class MethodDescriptorTest method testFindConstraintsMatchingGroups.

@Test
public void testFindConstraintsMatchingGroups() {
    MethodDescriptor descriptor = getMethodDescriptor(CustomerRepositoryExt.class, "methodWithCrossParameterConstraint", LocalDate.class, LocalDate.class);
    assertTrue(descriptor.findConstraints().getConstraintDescriptors().isEmpty());
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) ValidatorUtil.getMethodDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getMethodDescriptor) Test(org.testng.annotations.Test)

Example 8 with MethodDescriptor

use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.

the class MethodDescriptorTest method testIsReturnValueConstrainedForConstrainedMethod.

@Test
public void testIsReturnValueConstrainedForConstrainedMethod() {
    MethodDescriptor methodDescriptor = getMethodDescriptor(CustomerRepositoryExt.class, "baz");
    assertThat(methodDescriptor.hasConstrainedReturnValue()).isTrue();
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) ValidatorUtil.getMethodDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getMethodDescriptor) Test(org.testng.annotations.Test)

Example 9 with MethodDescriptor

use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.

the class MethodDescriptorTest method testGetElementClass.

@Test
public void testGetElementClass() {
    // the return type as defined in the base type
    MethodDescriptor methodDescriptor = getMethodDescriptor(CustomerRepository.class, "bar");
    assertEquals(methodDescriptor.getElementClass(), Customer.class);
    // the return type is now the one as defined in the derived type (covariant return type)
    methodDescriptor = getMethodDescriptor(CustomerRepositoryExt.class, "bar");
    assertEquals(methodDescriptor.getElementClass(), CustomerExtension.class);
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) ValidatorUtil.getMethodDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getMethodDescriptor) CustomerRepositoryExt(org.hibernate.validator.test.internal.metadata.CustomerRepositoryExt) IllegalCustomerRepositoryExt(org.hibernate.validator.test.internal.metadata.IllegalCustomerRepositoryExt) Test(org.testng.annotations.Test)

Example 10 with MethodDescriptor

use of jakarta.validation.metadata.MethodDescriptor in project hibernate-validator by hibernate.

the class MethodDescriptorTest method testGetConstraintDescriptors.

@Test
public void testGetConstraintDescriptors() {
    MethodDescriptor descriptor = getMethodDescriptor(CustomerRepository.class, "bar");
    assertTrue(descriptor.getConstraintDescriptors().isEmpty());
    descriptor = getMethodDescriptor(CustomerRepository.class, "methodWithCrossParameterConstraint", LocalDate.class, LocalDate.class);
    assertTrue(descriptor.getConstraintDescriptors().isEmpty());
}
Also used : CustomerRepository(org.hibernate.validator.test.internal.metadata.CustomerRepository) MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) ValidatorUtil.getMethodDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getMethodDescriptor) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

MethodDescriptor (jakarta.validation.metadata.MethodDescriptor)93 Test (org.testng.annotations.Test)86 AbstractTCKTest (org.hibernate.beanvalidation.tck.tests.AbstractTCKTest)49 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)44 BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)19 ValidatorUtil.getMethodDescriptor (org.hibernate.validator.testutils.ValidatorUtil.getMethodDescriptor)18 ParameterDescriptor (jakarta.validation.metadata.ParameterDescriptor)13 CrossParameterDescriptor (jakarta.validation.metadata.CrossParameterDescriptor)12 ReturnValueDescriptor (jakarta.validation.metadata.ReturnValueDescriptor)11 ConstraintMapping (org.hibernate.validator.cfg.ConstraintMapping)8 ValidatorUtil.getBeanDescriptor (org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor)7 ConstraintDescriptor (jakarta.validation.metadata.ConstraintDescriptor)5 ConstructorDescriptor (jakarta.validation.metadata.ConstructorDescriptor)4 SpecAssertions (org.jboss.test.audit.annotations.SpecAssertions)4 Validator (jakarta.validation.Validator)3 TestUtil.getMethodDescriptor (org.hibernate.beanvalidation.tck.util.TestUtil.getMethodDescriptor)3 TestForIssue (org.hibernate.validator.testutil.TestForIssue)3 Test (org.junit.Test)3 ConstraintValidator (jakarta.validation.ConstraintValidator)2 ValidatorFactory (jakarta.validation.ValidatorFactory)2