use of jakarta.validation.metadata.ParameterDescriptor in project hibernate-validator by hibernate.
the class ParameterDescriptorTest method testFindConstraintLookingAtLocalElement.
@Test(enabled = false, description = "Temporarily disabled due to HV-443")
public void testFindConstraintLookingAtLocalElement() {
Set<ConstraintDescriptor<?>> constraintDescriptors = createCustomerParameter2.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 0, "No local constraint for CustomerRepositoryExt#createCustomer(), arg1, expected.");
ParameterDescriptor createCustomerParameter2OnBaseType = getParameterDescriptor(CustomerRepository.class, "createCustomer", new Class<?>[] { CharSequence.class, String.class }, 1);
constraintDescriptors = createCustomerParameter2OnBaseType.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1, "One local constraint for CustomerRepository#createCustomer(), arg1, expected.");
}
use of jakarta.validation.metadata.ParameterDescriptor in project hibernate-validator by hibernate.
the class ParameterDescriptorTest method testIsCascaded.
@Test
public void testIsCascaded() {
assertFalse(createCustomerParameter1.isCascaded());
ParameterDescriptor saveCustomerParameter = getParameterDescriptor(CustomerRepositoryExt.class, "saveCustomer", new Class<?>[] { Customer.class }, 0);
assertTrue(saveCustomerParameter.isCascaded());
}
use of jakarta.validation.metadata.ParameterDescriptor in project hibernate-validator by hibernate.
the class ConstructorDescriptorTest method testGetParameterDescriptors.
@Test
public void testGetParameterDescriptors() {
ConstructorDescriptor constructorDescriptor = getConstructorDescriptor(CustomerRepositoryExt.class, String.class, Customer.class);
List<ParameterDescriptor> parameterDescriptors = constructorDescriptor.getParameterDescriptors();
assertThat(parameterDescriptors).hasSize(2);
ParameterDescriptor parameterDescriptor1 = parameterDescriptors.get(0);
assertThat(parameterDescriptor1.getElementClass()).isEqualTo(String.class);
assertThat(parameterDescriptor1.getIndex()).isEqualTo(0);
assertThat(parameterDescriptor1.getName()).isEqualTo("foo");
assertThat(parameterDescriptor1.hasConstraints()).isTrue();
assertThat(parameterDescriptor1.isCascaded()).isFalse();
ParameterDescriptor parameterDescriptor2 = parameterDescriptors.get(1);
assertThat(parameterDescriptor2.getElementClass()).isEqualTo(Customer.class);
assertThat(parameterDescriptor2.getIndex()).isEqualTo(1);
assertThat(parameterDescriptor2.getName()).isEqualTo("customer");
assertThat(parameterDescriptor2.hasConstraints()).isFalse();
assertThat(parameterDescriptor2.isCascaded()).isTrue();
}
use of jakarta.validation.metadata.ParameterDescriptor in project hibernate-validator by hibernate.
the class MethodDescriptorTest method testFindParameterConstraintLookingAt.
@Test
@TestForIssue(jiraKey = "HV-443")
public void testFindParameterConstraintLookingAt() {
ParameterDescriptor parameterDescriptor = getMethodDescriptor(CustomerRepositoryExt.class, "createCustomer", CharSequence.class, String.class).getParameterDescriptors().get(1);
Set<ConstraintDescriptor<?>> constraintDescriptors = parameterDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 0);
constraintDescriptors = parameterDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
assertEquals(constraintDescriptors.size(), 1);
assertEquals(constraintDescriptors.iterator().next().getAnnotation().annotationType(), NotNull.class);
}
use of jakarta.validation.metadata.ParameterDescriptor in project hibernate-validator by hibernate.
the class MethodDescriptorTest method testGetParameterConstraints.
@Test
public void testGetParameterConstraints() {
MethodDescriptor methodDescriptor = getMethodDescriptor(CustomerRepositoryExt.class, "createCustomer", CharSequence.class, String.class);
List<ParameterDescriptor> parameterConstraints = methodDescriptor.getParameterDescriptors();
assertNotNull(parameterConstraints);
assertEquals(parameterConstraints.size(), 2);
ParameterDescriptor parameterDescriptor1 = parameterConstraints.get(0);
assertEquals(parameterDescriptor1.getElementClass(), CharSequence.class);
assertFalse(parameterDescriptor1.hasConstraints());
ParameterDescriptor parameterDescriptor2 = parameterConstraints.get(1);
assertEquals(parameterDescriptor2.getElementClass(), String.class);
assertTrue(parameterDescriptor2.hasConstraints());
}
Aggregations