void testRemoveAll(HasOneToManyJDO pojo, BidirectionalSuperclassTableChildJDO.BidirTop bidir1,
BidirectionalSuperclassTableChildJDO.BidirTop bidir2, BidirectionalSuperclassTableChildJDO.BidirTop bidir3, StartEnd startEnd)
throws EntityNotFoundException {
UnidirTop unidir1 = new UnidirTop();
UnidirTop unidir2 = new UnidirMiddle();
UnidirTop unidir3 = new UnidirBottom();
pojo.addUnidirChild(unidir1);
pojo.addUnidirChild(unidir2);
pojo.addUnidirChild(unidir3);
pojo.addBidirChild(bidir1);
pojo.addBidirChild(bidir2);
pojo.addBidirChild(bidir3);
startEnd.start();
pm.makePersistent(pojo);
startEnd.end();
startEnd.start();
pojo = pm.makePersistent(pojo);
String unidir2Id = unidir2.getId();
String bidir2Id = bidir2.getId();
pojo.removeUnidirChildren(Collections.singleton(unidir2));
pojo.removeBidirChildren(Collections.singleton(bidir2));
startEnd.end();
startEnd.start();
pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
assertEquals(2, pojo.getUnidirChildren().size());
Set<String> unidirIds = Utils.newHashSet(unidir1.getId(), unidir2.getId(), unidir3.getId());
for (UnidirTop unidir : pojo.getUnidirChildren()) {
unidirIds.remove(unidir.getId());
}
assertEquals(1, unidirIds.size());
assertEquals(unidir2.getId(), unidirIds.iterator().next());
assertEquals(2, pojo.getBidirChildren().size());
Set<String> bidirIds = Utils.newHashSet(bidir1.getId(), bidir2.getId(), bidir3.getId());
for (BidirectionalSuperclassTableChildJDO.BidirTop b : pojo.getBidirChildren()) {
bidirIds.remove(b.getId());
}
assertEquals(1, bidirIds.size());
assertEquals(bidir2.getId(), bidirIds.iterator().next());
startEnd.end();
Entity unidirEntity1 = ds.get(KeyFactory.stringToKey(unidir1.getId()));
Entity unidirEntity3 = ds.get(KeyFactory.stringToKey(unidir3.getId()));
Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
if (isIndexed() && hasIndexPropertyInChild(pm)) {
// Only have index property when using older storageVersions
assertEquals(0L, unidirEntity1.getProperty("unidirChildren_INTEGER_IDX"));