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.getSuperParentSuperChildren().add(superChild);
beginTxn();
pm.makePersistent(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(Collections.singletonList(superParentSuperChildEntity.getKey()),
parentEntity.getProperty("superChildren"));
assertEquals(1, superParentSuperChildEntity.getProperties().size());
assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));
// lookup
beginTxn();
parent = pm.getObjectById(parent.getClass(), parent.getId());
assertEquals("super parent string", parent.getSuperParentString());
assertEquals("sub parent string", parent.getSubParentString());
assertEquals(1, parent.getSuperParentSuperChildren().size());
assertEquals(superChild.getId(), parent.getSuperParentSuperChildren().get(0).getId());
commitTxn();
beginTxn();
superChild = pm.getObjectById(superChild.getClass(), superChild.getId());
assertEquals("a string", superChild.getAString());
commitTxn();
// cascade delete
beginTxn();
pm.deletePersistent(parent);
commitTxn();
assertEquals(0, countForClass(parent.getClass()));
assertEquals(0, countForClass(superChild.getClass()));
}