Search in sources :

Example 26 with MethodDescriptor

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

the class ExecutableDescriptorTest method testGetParameterDescriptorsForMethod.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "b")
public void testGetParameterDescriptorsForMethod() {
    MethodDescriptor descriptor = Executables.parameterConstrainedMethod();
    assertEquals(descriptor.getParameterDescriptors().size(), 2, "Size of parameter descriptor list doesn't match method parameter count");
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 27 with MethodDescriptor

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

the class ExecutableDescriptorTest method testAreParametersConstrainedForCascadedMethod.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "e")
public void testAreParametersConstrainedForCascadedMethod() {
    MethodDescriptor descriptor = Executables.cascadedParameterMethod();
    assertTrue(descriptor.hasConstrainedParameters(), "Should be constrained on parameters");
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 28 with MethodDescriptor

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

the class ExecutableDescriptorTest method testGetElementClassForVoidMethod.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_ELEMENTDESCRIPTOR, id = "a")
public void testGetElementClassForVoidMethod() {
    MethodDescriptor descriptor = Executables.parameterConstrainedMethod();
    assertEquals(descriptor.getElementClass(), void.class);
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 29 with MethodDescriptor

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

the class ExecutableDescriptorTest method testIsReturnValueConstrainedForNotConstrainedMethod.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "f")
public void testIsReturnValueConstrainedForNotConstrainedMethod() {
    MethodDescriptor descriptor = Executables.cascadedParameterMethod();
    assertFalse(descriptor.hasConstrainedReturnValue(), "Should not be constrained on return value");
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 30 with MethodDescriptor

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

the class ExecutableDescriptorTest method testFindConstraintsForMethodDefinedOnSuperTypeLookingAt.

@Test
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_ELEMENTDESCRIPTOR, id = "d")
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_ELEMENTDESCRIPTOR, id = "g")
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_EXECUTABLEDESCRIPTOR, id = "g")
public void testFindConstraintsForMethodDefinedOnSuperTypeLookingAt() {
    MethodDescriptor crossParameterConstrainedDescriptor = Executables.crossParameterConstrainedMethodFromSuperType();
    assertEquals(crossParameterConstrainedDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors().size(), 0, "Should have no local constraints");
    assertTrue(crossParameterConstrainedDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors().isEmpty(), "Should have no hierarchy constraint");
}
Also used : MethodDescriptor(jakarta.validation.metadata.MethodDescriptor) AbstractTCKTest(org.hibernate.beanvalidation.tck.tests.AbstractTCKTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

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