Search in sources :

Example 16 with BeanDescriptor

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

the class BeanDescriptorTest method testIsTypeConstrainedForConstructorReturnValueConstrainedType.

@Test
public void testIsTypeConstrainedForConstructorReturnValueConstrainedType() {
    BeanDescriptor descriptor = getBeanDescriptor(ConstructorReturnValueConstrainedType.class);
    assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
    assertTrue(descriptor.getConstrainedMethods(MethodType.NON_GETTER, MethodType.GETTER).isEmpty(), "The entity should have no constrained methods");
    assertTrue(descriptor.getConstrainedConstructors().size() == 1, "The entity should have a constrained constructor");
}
Also used : ValidatorUtil.getBeanDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) Test(org.testng.annotations.Test)

Example 17 with BeanDescriptor

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

the class BeanDescriptorTest method testGetConstraintsForConstructor.

@Test
public void testGetConstraintsForConstructor() {
    BeanDescriptor descriptor = getBeanDescriptor(CustomerRepositoryExt.class);
    ConstructorDescriptor constructorDescriptor = descriptor.getConstraintsForConstructor(String.class, Customer.class);
    assertThat(constructorDescriptor).isNotNull();
}
Also used : ValidatorUtil.getBeanDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) ConstructorDescriptor(jakarta.validation.metadata.ConstructorDescriptor) Test(org.testng.annotations.Test)

Example 18 with BeanDescriptor

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

the class BeanDescriptorTest method testIsTypeConstrainedForConstructorCascadingParameterType.

@Test
public void testIsTypeConstrainedForConstructorCascadingParameterType() {
    BeanDescriptor descriptor = getBeanDescriptor(ConstructorCascadingParameterType.class);
    assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
    assertTrue(descriptor.getConstrainedMethods(MethodType.NON_GETTER).isEmpty(), "The entity should have no constrained methods");
    assertTrue(descriptor.getConstrainedConstructors().size() == 1, "The entity should have a constrained constructor");
}
Also used : ValidatorUtil.getBeanDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) Test(org.testng.annotations.Test)

Example 19 with BeanDescriptor

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

the class BeanDescriptorTest method testIsTypeConstrainedForConstructorCascadingReturnValueType.

@Test
public void testIsTypeConstrainedForConstructorCascadingReturnValueType() {
    BeanDescriptor descriptor = getBeanDescriptor(ConstructorCascadingReturnValueType.class);
    assertFalse(descriptor.isBeanConstrained(), "The entity should have no bean constraints");
    assertTrue(descriptor.getConstrainedMethods(MethodType.NON_GETTER, MethodType.GETTER).isEmpty(), "The entity should have no constrained methods");
    assertTrue(descriptor.getConstrainedConstructors().size() == 1, "The entity should have a constrained constructor");
}
Also used : ValidatorUtil.getBeanDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) Test(org.testng.annotations.Test)

Example 20 with BeanDescriptor

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

the class BeanDescriptorTest method testGetBeanDescriptor.

@Test
public void testGetBeanDescriptor() {
    BeanDescriptor beanDescriptor = getBeanDescriptor(CustomerRepository.class);
    assertNotNull(beanDescriptor);
    assertEquals(beanDescriptor.getElementClass(), CustomerRepository.class);
}
Also used : ValidatorUtil.getBeanDescriptor(org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) Test(org.testng.annotations.Test)

Aggregations

BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)116 Test (org.testng.annotations.Test)96 AbstractTCKTest (org.hibernate.beanvalidation.tck.tests.AbstractTCKTest)55 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)40 PropertyDescriptor (jakarta.validation.metadata.PropertyDescriptor)39 Validator (jakarta.validation.Validator)35 ValidatorUtil.getBeanDescriptor (org.hibernate.validator.testutils.ValidatorUtil.getBeanDescriptor)31 ConstraintDescriptor (jakarta.validation.metadata.ConstraintDescriptor)24 MethodDescriptor (jakarta.validation.metadata.MethodDescriptor)19 SpecAssertions (org.jboss.test.audit.annotations.SpecAssertions)15 ConstructorDescriptor (jakarta.validation.metadata.ConstructorDescriptor)10 Test (org.junit.Test)10 CrossParameterDescriptor (jakarta.validation.metadata.CrossParameterDescriptor)7 TestForIssue (org.hibernate.validator.testutil.TestForIssue)7 NotNull (jakarta.validation.constraints.NotNull)6 Default (jakarta.validation.groups.Default)6 TestUtil.getValidatorUnderTest (org.hibernate.beanvalidation.tck.util.TestUtil.getValidatorUnderTest)6 ConstraintValidator (jakarta.validation.ConstraintValidator)4 ConstraintViolation (jakarta.validation.ConstraintViolation)4 Annotation (java.lang.annotation.Annotation)4