final String propPath = "addresses[0]";
CascadingPropertyValidator v = validator.unwrap(CascadingPropertyValidator.class);
Author author = new Author();
author.setAddresses(new ArrayList<Address>());
Address adr = new Address();
author.getAddresses().add(adr);
Country country = new Country();
adr.setCity("dark");
adr.setCountry(country);
Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
Assert.assertEquals(1, iv.size()); // null address line 1 (no cascade)
country.setISO2Code("too_long");
iv = v.validateProperty(author, propPath, true);
Assert.assertEquals(3, iv.size()); // null address line 1 + null
// country.name + too long
// country.iso2code
country.setISO2Code("23");
iv = v.validateProperty(author, propPath, true);
Assert.assertEquals(2, iv.size()); // null address line 1 + null
// country.name, country.iso2code
// fixed
Address value = new Address();
value.setCity("whatever");
value.setAddressline1("1 address line");
iv = v.validateValue(Author.class, propPath, value, true);
Assert.assertEquals(1, iv.size()); // null country
value.setCountry(new Country());
iv = v.validateValue(Author.class, propPath, value, true);
Assert.assertEquals(1, iv.size()); // null country.name
value.getCountry().setName("NWO");
iv = v.validateValue(Author.class, propPath, value, true);
Assert.assertEquals(0, iv.size());
}