assertEquals(0, countForClass(superChild.getClass()));
}
public void testSuperParentWithSubChild() throws EntityNotFoundException {
// insertion
SuperParentWithSubChild parent = new SuperParentWithSubChild();
parent.setSuperParentString("super parent string");
SubChild subChild = new SubChild();
subChild.setAString("a string");
subChild.setBString("b string");
parent.setSuperParentSubChild(subChild);
beginTxn();
pm.makePersistent(parent);
commitTxn();
Entity parentEntity =
ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
Entity superParentSubChildEntity = ds.get(subChild.getId());
assertEquals(2, parentEntity.getProperties().size());
assertEquals("super parent string", parentEntity.getProperty("superParentString"));
assertEquals(superParentSubChildEntity.getKey(), parentEntity.getProperty("subChild_id_OID"));
assertEquals(2, superParentSubChildEntity.getProperties().size());
assertEquals("a string", superParentSubChildEntity.getProperty("aString"));
assertEquals("b string", superParentSubChildEntity.getProperty("bString"));
// lookup
beginTxn();
parent = pm.getObjectById(parent.getClass(), parent.getId());
assertEquals("super parent string", parent.getSuperParentString());
assertEquals(subChild.getId(), parent.getSuperParentSubChild().getId());
commitTxn();
beginTxn();
subChild = pm.getObjectById(subChild.getClass(), subChild.getId());
assertEquals("a string", subChild.getAString());
assertEquals("b string", subChild.getBString());
commitTxn();
// cascade delete
beginTxn();
pm.deletePersistent(parent);
commitTxn();
assertEquals(0, countForClass(parent.getClass()));
assertEquals(0, countForClass(subChild.getClass()));
}