assertEquals(0, countForClass(superChild.getClass()));
}
public void testSuperParentWithSuperChild() throws EntityNotFoundException {
// insertion
SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
parent.setSuperParentString("super parent string");
SuperChild superChild = new SuperChild();
superChild.setAString("a string");
parent.getSuperParentSuperChildren().add(superChild);
beginTxn();
em.persist(parent);
commitTxn();
Entity parentEntity =
ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
Entity superParentSuperChildEntity = ds.get(superChild.getId());
assertEquals(2, parentEntity.getProperties().size());
assertEquals("super parent string", parentEntity.getProperty("superParentString"));
assertEquals(Collections.singletonList(superParentSuperChildEntity.getKey()), parentEntity.getProperty("superChildren"));
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(1, parent.getSuperParentSuperChildren().size());
assertEquals(superChild.getId(), parent.getSuperParentSuperChildren().get(0).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()));
}