Search in sources :

Example 1 with TraversalContext

use of org.neo4j.graphdb.traversal.TraversalContext in project neo4j by neo4j.

the class TraversalBranchImplTest method shouldExpandOnFirstAccess.

@SuppressWarnings("unchecked")
@Test
public void shouldExpandOnFirstAccess() throws Exception {
    // GIVEN
    TraversalBranch parent = mock(TraversalBranch.class);
    Node source = mock(Node.class);
    TraversalBranchImpl branch = new TraversalBranchImpl(parent, source);
    @SuppressWarnings("rawtypes") PathExpander expander = mock(PathExpander.class);
    when(expander.expand(eq(branch), any(BranchState.class))).thenReturn(Collections.emptySet());
    TraversalContext context = mock(TraversalContext.class);
    when(context.evaluate(eq(branch), any(BranchState.class))).thenReturn(INCLUDE_AND_CONTINUE);
    // WHEN initializing
    branch.initialize(expander, context);
    // THEN the branch should not be expanded
    verifyZeroInteractions(source);
    // and WHEN actually traversing from it
    branch.next(expander, context);
    // THEN we should expand it
    verify(expander).expand(any(Path.class), any(BranchState.class));
}
Also used : Path(org.neo4j.graphdb.Path) Node(org.neo4j.graphdb.Node) PathExpander(org.neo4j.graphdb.PathExpander) TraversalContext(org.neo4j.graphdb.traversal.TraversalContext) BranchState(org.neo4j.graphdb.traversal.BranchState) TraversalBranch(org.neo4j.graphdb.traversal.TraversalBranch) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Node (org.neo4j.graphdb.Node)1 Path (org.neo4j.graphdb.Path)1 PathExpander (org.neo4j.graphdb.PathExpander)1 BranchState (org.neo4j.graphdb.traversal.BranchState)1 TraversalBranch (org.neo4j.graphdb.traversal.TraversalBranch)1 TraversalContext (org.neo4j.graphdb.traversal.TraversalContext)1