!cons.getConstraintsForProperty("unconstraintField").hasConstraints());
assertNull(cons.getConstraintsForProperty("unknownField"));
}
public void testValidateValue() {
Validator validator = getValidator();
assertTrue(
validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
assertFalse(validator.validateValue(Book.class, "subtitle",
"123456789098765432123412345678909876543212341234564567890987654321234",
Second.class).isEmpty());
// tests for issue 22: validation of a field without any constraints
assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
// tests for issue 22: validation of unknown field cause ValidationException
try {
validator.validateValue(Book.class, "unknownProperty", 4);
fail("unknownProperty not detected");
} catch (IllegalArgumentException ex) {
// OK
assertEquals(
"unknown property 'unknownProperty' in org.apache.bval.jsr303.example.Book",