set2.add(orange4);
TestObject to = newInstance(TestObject.class);
to.setSetToArray(set);
to.setSetToObjectArray(set2);
TestObjectPrime top = mapper.map(to, TestObjectPrime.class);
Set<String> fruitNames = new HashSet<String>();
fruitNames.add(top.getArrayToSet()[0].getName());
fruitNames.add(top.getArrayToSet()[1].getName());
assertTrue(fruitNames.remove("orange1"));
assertTrue(fruitNames.remove("orange2"));
fruitNames.add(((Apple) top.getObjectArrayToSet()[0]).getName());
fruitNames.add(((Apple) top.getObjectArrayToSet()[1]).getName());
assertTrue(fruitNames.remove("orange3"));
assertTrue(fruitNames.remove("orange4"));
Apple apple = newInstance(Apple.class);
apple.setName("apple1");
Apple[] appleArray = { apple };
top.setSetToArrayWithValues(appleArray);
// now map back
Apple apple2 = newInstance(Apple.class);
apple2.setName("apple2");
TestObject toDest = newInstance(TestObject.class);
Set<Apple> hashSet = newInstance(HashSet.class);
hashSet.add(apple2);
toDest.setSetToArrayWithValues(hashSet);
mapper.map(top, toDest);
assertTrue(toDest.getSetToArray().contains(top.getArrayToSet()[0]));
assertTrue(toDest.getSetToArray().contains(top.getArrayToSet()[1]));
assertTrue(toDest.getSetToObjectArray().contains(top.getObjectArrayToSet()[0]));
assertTrue(toDest.getSetToObjectArray().contains(top.getObjectArrayToSet()[1]));
assertTrue(toDest.getSetToArrayWithValues().contains(apple));
assertTrue(toDest.getSetToArrayWithValues().contains(apple2));
assertTrue(toDest.getSetToArrayWithValues() instanceof HashSet);
}