createThingsAndLinks();
Index<Node> typesIndex = graphDatabaseService.index().forNodes(IndexingNodeTypeRepresentationStrategy.INDEX_NAME);
IndexHits<Node> thingHits;
IndexHits<Node> subThingHits;
Transaction tx = graphDatabaseService.beginTx();
try
{
nodeTypeRepresentationStrategy.preEntityRemoval(node(thing));
tx.success();
}
finally
{
tx.finish();
}
thingHits = typesIndex.get(IndexingNodeTypeRepresentationStrategy.INDEX_KEY, thing.getClass().getName());
assertEquals(node(subThing), thingHits.getSingle());
subThingHits = typesIndex.get(IndexingNodeTypeRepresentationStrategy.INDEX_KEY, subThing.getClass().getName());
assertEquals(node(subThing), subThingHits.getSingle());
tx = graphDatabaseService.beginTx();
try {
nodeTypeRepresentationStrategy.preEntityRemoval(node(subThing));
tx.success();
}
finally
{
tx.finish();
}
thingHits = typesIndex.get(IndexingNodeTypeRepresentationStrategy.INDEX_KEY, thing.getClass().getName());
assertNull(thingHits.getSingle());
subThingHits = typesIndex.get(IndexingNodeTypeRepresentationStrategy.INDEX_KEY, subThing.getClass().getName());