StartEnd startEnd, UnidirLevel unidirLevel,
int expectedParent, int expectedChildren)
throws Exception {
bidirChild.setChildVal("yam");
UnidirTop unidir = newUnidir(unidirLevel);
String expectedName = unidir.getName();
String expectedStr = unidir.getStr();
HasKeyPkJPA hasKeyPk = new HasKeyPkJPA();
hasKeyPk.setStr("yag");
parent.getBidirChildren().add(bidirChild);
bidirChild.setParent(parent);
parent.getUnidirChildren().add(unidir);
parent.getHasKeyPks().add(hasKeyPk);
parent.setVal("yar");
startEnd.start();
em.persist(parent);
startEnd.end();
assertNotNull(bidirChild.getId());
assertNotNull(unidir.getId());
assertNotNull(hasKeyPk.getId());
Entity bidirChildEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
assertNotNull(bidirChildEntity);
assertEquals(bidirChild.getClass().getName(), bidirChildEntity.getProperty("DTYPE"));
assertEquals(bidirChild.getPropertyCount(), bidirChildEntity.getProperties().size());
assertEquals("yam", bidirChildEntity.getProperty("childVal"));
assertEquals(KeyFactory.stringToKey(bidirChild.getId()), bidirChildEntity.getKey());
assertKeyParentEquals(parent.getId(), bidirChildEntity, bidirChild.getId());
Entity unidirEntity = ds.get(KeyFactory.stringToKey(unidir.getId()));
assertNotNull(unidirEntity);
assertEquals(unidirLevel.discriminator, unidirEntity.getProperty("DTYPE"));
assertEquals(expectedName, unidirEntity.getProperty("name"));
assertEquals(expectedStr, unidirEntity.getProperty("str"));
assertEquals(KeyFactory.stringToKey(unidir.getId()), unidirEntity.getKey());
assertKeyParentEquals(parent.getId(), unidirEntity, unidir.getId());
Entity hasKeyPkEntity = ds.get(hasKeyPk.getId());
assertNotNull(hasKeyPkEntity);
assertEquals("yag", hasKeyPkEntity.getProperty("str"));
assertEquals(hasKeyPk.getId(), hasKeyPkEntity.getKey());