public void testValidateMapAndRedefinedDefaultGroupOnNonRootBean() {
Library lib = new Library();
lib.setLibraryName("Leibnitz Bibliothek");
Book book1, book2, book3;
book1 = new Book();
book1.setTitle("History of time");
book1.setSubtitle("How it really works");
Author hawking = new Author();
hawking.setFirstName("Stephen");
hawking.setFirstName("Hawking");
hawking.setAddresses(new ArrayList<Address>(1));
Address adr = new Address();
adr.setAddressline1("Street 1");
adr.setCity("London");
adr.setCountry(new Country());
adr.getCountry().setName("England");
hawking.getAddresses().add(adr);
book1.setAuthor(hawking);
book2 = new Book();
Author castro = new Author();
castro.setFirstName("Fidel");
castro.setLastName("Castro Ruz");
book2.setAuthor(castro);
book2.setTitle("My life");
book3 = new Book();
book3.setTitle("World best jokes");
Author someone = new Author();
someone.setFirstName("John");
someone.setLastName("Do");
book3.setAuthor(someone);
lib.getTaggedBooks().put("science", book1);
lib.getTaggedBooks().put("politics", book2);
lib.getTaggedBooks().put("humor", book3);
Set<ConstraintViolation<Library>> violations;
violations = validator.validate(lib);
assertTrue(violations.isEmpty());
book2.setTitle(null);
book3.getAuthor().setFirstName(""); // violate NotEmpty validation
book1.getAuthor().getAddresses().get(0).setCity(null);
/*
* This, by the way, tests redefined default group sequence behavior on
* non-root-beans (Library.Book)!!
*/
violations = validator.validate(lib);