MapperFactory factory = MappingUtil.getMapperFactory();
factory.registerMappingHint(myHint);
factory.build();
MapperFacade mapper = factory.getMapperFacade();
Book book = createBook(BookParent.class);
book.setAuthor(createAuthor(AuthorParent.class));
Library lib = createLibrary(LibraryParent.class);
lib.getBooks().add(book);
LibraryMyDTO mappedLib = mapper.map(lib, LibraryMyDTO.class);
Assert.assertEquals(lib.getTitle(), mappedLib.getMyTitle());
Assert.assertEquals(book.getTitle(), mappedLib.getMyBooks().get(0).getMyTitle());
Assert.assertEquals(book.getAuthor().getName(), mappedLib.getMyBooks().get(0).getMyAuthor().getMyName());
// Now, map it back to the original...
Library lib2 = mapper.map(mappedLib, Library.class);
Assert.assertEquals(lib.getTitle(), lib2.getTitle());
Assert.assertEquals(book.getTitle(), lib2.getBooks().get(0).getTitle());
Assert.assertEquals(book.getAuthor().getName(), lib2.getBooks().get(0).getAuthor().getName());
}