use of org.hibernate.validator.test.internal.metadata.Engine in project hibernate-validator by hibernate.
the class ConstraintHelperTest method testGetConstraintsFromMultiValueConstraint.
@Test
public void testGetConstraintsFromMultiValueConstraint() throws Exception {
Engine engine = new Engine();
Field field = engine.getClass().getDeclaredField("serialNumber");
Annotation annotation = field.getAnnotation(Pattern.List.class);
assertNotNull(annotation);
List<Annotation> multiValueConstraintAnnotations = constraintHelper.getConstraintsFromMultiValueConstraint(annotation);
assertTrue(multiValueConstraintAnnotations.size() == 2, "There should be two constraint annotations");
assertTrue(multiValueConstraintAnnotations.get(0) instanceof Pattern, "Wrong constraint annotation");
assertEquals(((Pattern) multiValueConstraintAnnotations.get(0)).regexp(), "^[A-Z0-9-]+$");
assertTrue(multiValueConstraintAnnotations.get(1) instanceof Pattern, "Wrong constraint annotation");
assertEquals(((Pattern) multiValueConstraintAnnotations.get(1)).regexp(), "^....-....-....$");
}
Aggregations