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));
}
Aggregations