List<String> mappingFiles = new ArrayList<String>();
mappingFiles.add("interface-recursion-mappings.xml");
Mapper mapper = new DozerBeanMapper(mappingFiles);
// do mapping
UserGroupPrime userGroupPrime = null;
try {
userGroupPrime = mapper.map(userGroup, UserGroupPrime.class);
} catch (StackOverflowError e) {
fail("Recursive mapping caused a stack overflow.");
}
// check mapped group
assertNotNull(userGroupPrime);
assertEquals(userGroup.getName(), userGroupPrime.getName());
// check mapped users and recursion
assertEquals("Two users in mapped usergroup expected.", 2, userGroupPrime.getUsers().size());
iterator = userGroupPrime.getUsers().iterator();
while (iterator.hasNext()) {
UserPrime userPrime = (UserPrime) iterator.next();
assertNotNull(userPrime);
assertNotNull(userPrime.getUserGroup());
assertTrue(userPrime.getUserGroup() == userGroupPrime); // same reference