testOneToManyChildAtMultipleLevels(startEnd, UnidirLevel.Middle, UnidirLevel.Bottom, 2);
testOneToManyChildAtMultipleLevels(startEnd, UnidirLevel.Bottom, UnidirLevel.Bottom, 3);
}
private void testOneToManyChildAtMultipleLevels(StartEnd startEnd,
UnidirLevel unidirLevel1, UnidirLevel unidirLevel2, int count) {
HasOneToManyChildAtMultipleLevels pojo = new HasOneToManyChildAtMultipleLevels();
UnidirTop unidir1 = newUnidir(unidirLevel1);
pojo.setUnidirChildren(Utils.newArrayList(unidir1));
HasOneToManyChildAtMultipleLevels child = new HasOneToManyChildAtMultipleLevels();
UnidirTop unidir2 = newUnidir(unidirLevel2);
child.setUnidirChildren(Utils.newArrayList(unidir2));
pojo.setChild(child);
startEnd.start();
pm.makePersistent(pojo);
startEnd.end();
startEnd.start();
assertEquals(2 * count, countForClass(UnidirTop.class));
pojo = pm.getObjectById(HasOneToManyChildAtMultipleLevels.class, pojo.getId());
assertEquals(child.getId(), pojo.getChild().getId());
assertEquals(1, pojo.getUnidirChildren().size());
assertTrue(pojo.getUnidirChildren().get(0).customEquals(unidir1));
assertTrue(child.getUnidirChildren().get(0).customEquals(unidir2));
assertEquals(1, child.getUnidirChildren().size());
startEnd.end();
}