//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBidirectionalPath() public virtual void TestBidirectionalPath() { TraversalDescription side = GraphDb.traversalDescription().uniqueness(Uniqueness.NODE_PATH); BidirectionalTraversalDescription bidirectional = GraphDb.bidirectionalTraversalDescription().mirroredSides(side); Path bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); AssertPathIsCorrect(bidirectionalPath); Path path = GetFirstPath(bidirectional.Traverse(_a, _e)); Node node = path.StartNode(); assertEquals(_a, node); // White box testing below: relationships(), nodes(), reverseRelationships(), reverseNodes() // does cache the start node if not already cached, so just make sure they to it properly. bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Relationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Nodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseRelationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseNodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.GetEnumerator(); assertEquals(_a, bidirectionalPath.StartNode()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPathIterator() public virtual void TestPathIterator() { Traverser traverse = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(Node("A")); using (ResourceIterator <Path> resourceIterator = traverse.GetEnumerator()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Path path = resourceIterator.next(); AssertPathIsCorrect(path); } }
protected internal override Relationship fetchNextOrNull() { while (_pathIterator.MoveNext()) { Path path = _pathIterator.Current; if (path.Length() > 0) { return(path.LastRelationship()); } } return(null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reverseNodes() public virtual void ReverseNodes() { Traverser traverse = GraphDb.traversalDescription().evaluator(atDepth(0)).traverse(_a); Path path = GetFirstPath(traverse); AssertContains(path.ReverseNodes(), _a); Traverser traverse2 = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(_a); Path path2 = GetFirstPath(traverse2); AssertContainsInOrder(path2.ReverseNodes(), _e, _d, _c, _b, _a); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reverseRelationships() public virtual void ReverseRelationships() { Traverser traverser = GraphDb.traversalDescription().evaluator(atDepth(0)).traverse(_a); Path path = GetFirstPath(traverser); assertFalse(path.ReverseRelationships().GetEnumerator().hasNext()); Traverser traverser2 = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(_a); Path path2 = GetFirstPath(traverser2); Node[] expectedNodes = new Node[] { _e, _d, _c, _b, _a }; int index = 0; foreach (Relationship rel in path2.ReverseRelationships()) { assertEquals("For index " + index, expectedNodes[index++], rel.EndNode); } assertEquals(4, index); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void ensureCorrectPathEntitiesInShortPath() public virtual void EnsureCorrectPathEntitiesInShortPath() { /* * (a)-->(b) */ CreateGraph("a TO b"); Node a = GetNodeWithName("a"); Node b = GetNodeWithName("b"); Relationship r = a.GetSingleRelationship(To, OUTGOING); Path path = Iterables.single(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().relationships(To, OUTGOING).uniqueness(NODE_PATH)).collisionEvaluator(Evaluators.atDepth(1)).sideSelector(SideSelectorPolicies.LEVEL, 1).traverse(a, b)); AssertContainsInOrder(path.Nodes(), a, b); AssertContainsInOrder(path.ReverseNodes(), b, a); AssertContainsInOrder(path.Relationships(), r); AssertContainsInOrder(path.ReverseRelationships(), r); AssertContainsInOrder(path, a, r, b); assertEquals(a, path.StartNode()); assertEquals(b, path.EndNode()); assertEquals(r, path.LastRelationship()); }
private void AssertPathIsCorrect(Path path) { Node a = Node("A"); Relationship to1 = GetFistRelationship(a); Node b = to1.EndNode; Relationship to2 = GetFistRelationship(b); Node c = to2.EndNode; Relationship to3 = GetFistRelationship(c); Node d = to3.EndNode; Relationship to4 = GetFistRelationship(d); Node e = to4.EndNode; assertEquals(( int? )4, ( int? )path.Length()); assertEquals(a, path.StartNode()); assertEquals(e, path.EndNode()); assertEquals(to4, path.LastRelationship()); AssertContainsInOrder(path, a, to1, b, to2, c, to3, d, to4, e); AssertContainsInOrder(path.Nodes(), a, b, c, d, e); AssertContainsInOrder(path.Relationships(), to1, to2, to3, to4); AssertContainsInOrder(path.ReverseNodes(), e, d, c, b, a); AssertContainsInOrder(path.ReverseRelationships(), to4, to3, to2, to1); }
protected internal override Node convert(Path path) { return(path.EndNode()); }
protected internal abstract T Convert(Path path);
protected internal override Relationship convert(Path path) { return(path.LastRelationship()); }
protected internal override bool includePath(Path path, TraversalBranch startPath, TraversalBranch endPath) { assertEquals(0, startPath.State()); assertEquals(10, endPath.State()); return(true); }