use of org.neo4j.graphdb.index.ReadableRelationshipIndex in project neo4j by neo4j.
the class AutoIndexOperationsTest method shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode.
@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() {
RelationshipType type = MyRelTypes.TEST;
long startId;
long endId;
Relationship rel;
try (Transaction tx = db.beginTx()) {
Node start = db.createNode();
Node end = db.createNode();
startId = start.getId();
endId = end.getId();
rel = start.createRelationshipTo(end, type);
rel.setProperty("Type", type.name());
tx.success();
}
try (Transaction tx = db.beginTx()) {
ReadableRelationshipIndex autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
Node start = db.getNodeById(startId);
Node end = db.getNodeById(endId);
IndexHits<Relationship> hits = autoRelationshipIndex.get("Type", type.name(), start, end);
assertEquals(1, count(hits));
assertEquals(1, hits.size());
rel.delete();
autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
hits = autoRelationshipIndex.get("Type", type.name(), start, end);
assertEquals(0, count(hits));
assertEquals(0, hits.size());
tx.success();
}
}
Aggregations