VarDependencies { public List<Relationship> getRelationships(ClauseId clauseId) { return Collections.unmodifiableList(this.relationships.get(clauseId)); } VarDependencies(final Statement statement); List<Var> getUsedVars(ClauseId clauseId); Set<Var> getAllVariables(); List<Var> getUsedAndIndirectUsedVars(ClauseId clauseId); AvailableVariables getReachableVars(ClauseId clauseId); List<Relationship> getRelationships(ClauseId clauseId); List<Expr> getReturnExprs();  }
@Test public void testRelationships() { String cypher = "" + "MATCH (a)--(b)\n" + "RETURN 42"; Statement st = PassAvailables.parseCypher(cypher); SingleQuery sq = (SingleQuery) st.query.part; VarDependencies dependencies = new VarDependencies(st); Match match = ((Match) sq.clauses.iterator().next()); Iterator<PatternPart> iter = this.getPatternPart(match); List<Relationship> match0 = dependencies.getRelationships(this.genClauseForASTNode(iter.next())); Assert.assertEquals(match0.size(), 1); Assert.assertEquals(match0.get(0).leftNode.name, "a"); Assert.assertEquals(match0.get(0).rightNode.name, "b"); }
@Test public void testRelationshipsPathOrder() { String cypher = "" + "MATCH (a)--(b)--(c)\n" + "RETURN 42"; Statement st = PassAvailables.parseCypher(cypher); SingleQuery sq = (SingleQuery) st.query.part; VarDependencies dependencies = new VarDependencies(st); Match match = ((Match) sq.clauses.iterator().next()); Iterator<PatternPart> iter = this.getPatternPart(match); List<Relationship> match0 = dependencies.getRelationships(this.genClauseForASTNode(iter.next())); Assert.assertEquals(match0.size(), 2); Assert.assertEquals(match0.get(0).leftNode.name, "a"); Assert.assertEquals(match0.get(0).rightNode.name, "b"); Assert.assertEquals(match0.get(1).leftNode.name, "b"); Assert.assertEquals(match0.get(1).rightNode.name, "c"); Assert.assertSame(match0.get(0).rightNode, match0.get(1).leftNode); }