// assertEquals(ElementType.FIELD, desc.getElementType());
Assert.assertEquals(String.class, desc.getElementClass());
}
public void testMetadataAPI_Address() {
Validator validator = getValidator();
Assert.assertFalse(validator.getConstraintsForClass(Address.class)
.getConstraintDescriptors().isEmpty());
Set<PropertyDescriptor> props =
validator.getConstraintsForClass(Address.class).getConstrainedProperties();
Set<String> propNames = new HashSet(props.size());
for (PropertyDescriptor each : props) {
propNames.add(each.getPropertyName());
}
Assert.assertTrue(propNames.contains("addressline1")); // annotated at field level
Assert.assertTrue(propNames.contains("addressline2"));
Assert.assertTrue(propNames.contains("zipCode"));
Assert.assertTrue(propNames.contains("country"));
Assert.assertTrue(propNames.contains("city")); // annotated at method level
Assert.assertEquals(5, props.size());
ElementDescriptor desc = validator.getConstraintsForClass(Address.class)
.getConstraintsForProperty("addressline1");
Assert.assertNotNull(desc);
boolean found = false;
for (ConstraintDescriptor each : desc.getConstraintDescriptors()) {
if (each.getConstraintValidatorClasses().get(0)