public void testValidateCascadingKeyedGenericElement() throws InvocationTargetException, NoSuchMethodException,
IllegalAccessException {
final String propPath = "[foo]";
CascadingPropertyValidator v = validator.unwrap(CascadingPropertyValidator.class);
final Address adr = new Address();
Object map = new HashMap<String, Address>();
((Map<String, Address>) map).put("foo", adr);
Country country = new Country();
adr.setCity("dark");
adr.setCountry(country);
Set<?> iv = v.validateProperty(map, propPath);
Assert.assertEquals(1, iv.size()); // null address line 1 (no cascade)
country.setISO2Code("too_long");
iv = v.validateProperty(map, propPath, true);
Assert.assertEquals(3, iv.size()); // null address line 1 + null
// country.name + too long
// country.iso2code
country.setISO2Code("23");
iv = v.validateProperty(map, 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");
Set<?> iv2 = v.validateValue(Map.class, propPath, value, true);
Assert.assertEquals(1, iv2.size()); // null country
value.setCountry(new Country());
iv2 = v.validateValue(Map.class, propPath, value, true);
Assert.assertEquals(1, iv2.size()); // null country.name
value.getCountry().setName("NWO");
iv2 = v.validateValue(Map.class, propPath, value, true);
Assert.assertEquals(0, iv2.size());
}