assertEquals(0, countForClass(subChild.getClass()));
}
public void testSubParentWithSuperChild() throws EntityNotFoundException {
// insertion
SubParentWithSuperChild parent = new SubParentWithSuperChild();
parent.setSuperParentString("super parent string");
parent.setSubParentString("sub parent string");
SuperChild superChild = new SuperChild();
superChild.setAString("a string");
parent.setSuperParentSuperChild(superChild);
beginTxn();
em.persist(parent);
commitTxn();
Entity parentEntity =
ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
Entity superParentSuperChildEntity = ds.get(superChild.getId());
assertEquals(3, parentEntity.getProperties().size());
assertEquals("super parent string", parentEntity.getProperty("superParentString"));
assertEquals("sub parent string", parentEntity.getProperty("subParentString"));
assertEquals(superParentSuperChildEntity.getKey(), parentEntity.getProperty("superChild_id"));
assertEquals(1, superParentSuperChildEntity.getProperties().size());
assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));
// lookup
beginTxn();
parent = em.find(parent.getClass(), parent.getId());
assertEquals("super parent string", parent.getSuperParentString());
assertEquals("sub parent string", parent.getSubParentString());
assertEquals(superChild.getId(), parent.getSuperParentSuperChild().getId());
commitTxn();
beginTxn();
superChild = em.find(superChild.getClass(), superChild.getId());
assertEquals("a string", superChild.getAString());
commitTxn();
// cascade delete
beginTxn();
em.remove(em.merge(parent));
commitTxn();
assertEquals(0, countForClass(parent.getClass()));
assertEquals(0, countForClass(superChild.getClass()));
}