Search in sources :

Example 11 with Traverser

use of org.neo4j.graphdb.Traverser in project graphdb by neo4j-attic.

the class TestTraversal method testBruteDepthTraversal.

// Traverses the full test "ise-tree-like" population depth first
// and verifies that it is returned in correct order
@Test
public void testBruteDepthTraversal() throws Exception {
    Node root = this.buildIseTreePopulation();
    RelationshipType[] traversableRels = new RelationshipType[] { MyRelTypes.TEST, MyRelTypes.TEST_TRAVERSAL };
    Traverser traverser = root.traverse(DEPTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL, traversableRels[0], Direction.BOTH, traversableRels[1], Direction.BOTH);
    try {
        this.assertNodes(traverser, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14");
        assertTrue("Too many nodes returned from traversal", traverser.iterator().hasNext() == false);
    } catch (java.util.NoSuchElementException nsee) {
        fail("Too few nodes returned from traversal");
    } finally {
        this.deleteNodeTreeRecursively(root, 0);
    }
}
Also used : Node(org.neo4j.graphdb.Node) Traverser(org.neo4j.graphdb.Traverser) RelationshipType(org.neo4j.graphdb.RelationshipType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 Node (org.neo4j.graphdb.Node)11 Traverser (org.neo4j.graphdb.Traverser)11 RelationshipType (org.neo4j.graphdb.RelationshipType)10 TraversalPosition (org.neo4j.graphdb.TraversalPosition)7 StopEvaluator (org.neo4j.graphdb.StopEvaluator)6 NotFoundException (org.neo4j.graphdb.NotFoundException)3 ReturnableEvaluator (org.neo4j.graphdb.ReturnableEvaluator)3 Relationship (org.neo4j.graphdb.Relationship)2 DynamicRelationshipType (org.neo4j.graphdb.DynamicRelationshipType)1 Transaction (org.neo4j.graphdb.Transaction)1