Paths { @UserFunction @Description("apoc.path.elements(path) - returns a list of node-relationship-node-...") public List<Object> elements(@Name("path") Path path) { if (path == null) return null; return Iterables.asList((Iterable)path); }  @UserFunction @Description("apoc.path.create(startNode,[rels]) - creates a path instance of the given elements") Path create(@Name("startNode") Node startNode, @Name(value = "rels", defaultValue = "[]") List<Relationship> rels); @UserFunction @Description("apoc.path.slice(path, [offset], [length]) - creates a sub-path with the given offset and length") Path slice(@Name("path") Path path, @Name(value = "offset", defaultValue = "0") long offset,@Name(value = "length", defaultValue = "-1") long length); @UserFunction @Description("apoc.path.combine(path1, path2) - combines the paths into one if the connecting node matches") Path combine(@Name("first") Path first, @Name("second") Path second); @UserFunction @Description("apoc.path.elements(path) - returns a list of node-relationship-node-...") List<Object> elements(@Name("path") Path path);  }
@Test public void elements() throws Exception { TestUtil.testCall(db, "MATCH p = (a:A) RETURN apoc.path.elements(p) as e",(row) -> { List<Entity> pc = (List<Entity>) row.get("e"); assertEquals(1,pc.size()); assertEquals(true,((Node)pc.get(0)).hasLabel(Label.label("A"))); }); TestUtil.testCall(db, "MATCH p = (a:A)-->() RETURN apoc.path.elements(p) as e",(row) -> { List<Entity> pc = (List<Entity>) row.get("e"); assertEquals(3,pc.size()); assertEquals(true,((Node)pc.get(0)).hasLabel(Label.label("A"))); assertEquals(true,((Relationship)pc.get(1)).isType(RelationshipType.withName("NEXT"))); assertEquals(true,((Node)pc.get(2)).hasLabel(Label.label("B"))); }); }