Esempio n. 1
0
//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());
        }
Esempio n. 2
0
//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());
        }
Esempio n. 3
0
        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);
        }