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(expected = IllegalArgumentException.class) public void bothSidesMustHaveSameUniqueness()
        public virtual void BothSidesMustHaveSameUniqueness()
        {
            CreateGraph("A TO B");

            Traverser traverse = GraphDb.bidirectionalTraversalDescription().startSide(GraphDb.traversalDescription().uniqueness(Uniqueness.NODE_GLOBAL)).endSide(GraphDb.traversalDescription().uniqueness(Uniqueness.RELATIONSHIP_GLOBAL)).traverse(GetNodeWithName("A"), GetNodeWithName("B"));

            using (ResourceIterator <Path> iterator = traverse.GetEnumerator())
            {
                Iterators.count(iterator);
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mirroredTraversalReversesInitialState()
        public virtual void MirroredTraversalReversesInitialState()
        {
            /*
             * (a)-->(b)-->(c)-->(d)
             */
            CreateGraph("a TO b", "b TO c", "c TO d");

            BranchCollisionPolicy collisionPolicy = (evaluator, pathPredicate) => new StandardBranchCollisionDetectorAnonymousInnerClass(this);

            Iterables.count(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(PathExpanders.forType(To), new Org.Neo4j.Graphdb.traversal.InitialBranchState_State <>(0, 10))).collisionPolicy(collisionPolicy).traverse(GetNodeWithName("a"), GetNodeWithName("d")));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pathsForOneDirection()
        public virtual void PathsForOneDirection()
        {
            /*
             * (a)-->(b)==>(c)-->(d)
             *   ^               /
             *    \--(f)<--(e)<-/
             */
            CreateGraph("a TO b", "b TO c", "c TO d", "d TO e", "e TO f", "f TO a");

            PathExpander <Void> expander = PathExpanders.forTypeAndDirection(To, OUTGOING);

            ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(expander)).traverse(GetNodeWithName("a"), GetNodeWithName("f")), "a,b,c,d,e,f");

            ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(RELATIONSHIP_PATH).expand(expander)).traverse(GetNodeWithName("a"), GetNodeWithName("f")), "a,b,c,d,e,f", "a,b,c,d,e,f");
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleCollisionEvaluators()
        public virtual void MultipleCollisionEvaluators()
        {
            /*
             *           (g)
             *           ^ \
             *          /   v
             *  (a)-->(b)   (c)
             *   |        --^ ^
             *   v       /    |
             *  (d)-->(e)----(f)
             */
            CreateGraph("a TO b", "b TO g", "g TO c", "a TO d", "d TO e", "e TO c", "e TO f", "f TO c");

            ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH)).collisionEvaluator(Evaluators.atDepth(3)).collisionEvaluator(includeIfContainsAll(GetNodeWithName("e"))).traverse(GetNodeWithName("a"), GetNodeWithName("c")), "a,d,e,c");
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleStartAndEndNodes()
        public virtual void MultipleStartAndEndNodes()
        {
            /*
             * (a)--\         -->(f)
             *       v       /
             * (b)-->(d)<--(e)-->(g)
             *       ^
             * (c)--/
             */
            CreateGraph("a TO d", "b TO d", "c TO d", "e TO d", "e TO f", "e TO g");

            PathExpander <Void>  expander = PathExpanderBuilder.empty().add(To).build();
            TraversalDescription side     = GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(expander);

            ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(side).traverse(asList(GetNodeWithName("a"), GetNodeWithName("b"), GetNodeWithName("c")), asList(GetNodeWithName("f"), GetNodeWithName("g"))), "a,d,e,f", "a,d,e,g", "b,d,e,f", "b,d,e,g", "c,d,e,f", "c,d,e,g");
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void collisionEvaluator()
        public virtual void CollisionEvaluator()
        {
            /*
             *           (d)-->(e)--
             *            ^     |   \
             *            |     v    v
             *           (a)-->(b)<--(f)
             *            |    ^
             *            v   /
             *           (c)-/
             */
            CreateGraph("a TO b", "a TO c", "c TO b", "a TO d", "d TO e", "e TO b", "e TO f", "f TO b");

            PathExpander <Void> expander = PathExpanders.forTypeAndDirection(To, OUTGOING);
            BidirectionalTraversalDescription traversal = GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(expander));

            ExpectPaths(traversal.CollisionEvaluator(includeIfContainsAll(GetNodeWithName("e"))).traverse(GetNodeWithName("a"), GetNodeWithName("b")), "a,d,e,b", "a,d,e,f,b");
            ExpectPaths(traversal.CollisionEvaluator(includeIfContainsAll(GetNodeWithName("e"), GetNodeWithName("f"))).traverse(GetNodeWithName("a"), GetNodeWithName("b")), "a,d,e,f,b");
        }
Esempio n. 8
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());
        }