### Question:
StandardBranchCollisionDetector implements BranchCollisionDetector { @Override @SuppressWarnings( "unchecked" ) public Collection<Path> evaluate( TraversalBranch branch, Direction direction ) { Collection<TraversalBranch>[] pathsHere = paths.get( branch.endNode() ); int index = direction.ordinal(); if ( pathsHere == null ) { pathsHere = new Collection[] {new ArrayList<>(), new ArrayList<>() }; paths.put( branch.endNode(), pathsHere ); } pathsHere[index].add( branch ); Collection<TraversalBranch> otherCollections = pathsHere[index == 0 ? 1 : 0]; if ( !otherCollections.isEmpty() ) { Collection<Path> foundPaths = new ArrayList<>(); for ( TraversalBranch otherBranch : otherCollections ) { TraversalBranch startPath = index == 0 ? branch : otherBranch; TraversalBranch endPath = index == 0 ? otherBranch : branch; BidirectionalTraversalBranchPath path = new BidirectionalTraversalBranchPath( startPath, endPath ); if ( isAcceptablePath( path ) ) { if ( returnedPaths.add( path ) && includePath( path, startPath, endPath ) ) { foundPaths.add( path ); } } } if ( !foundPaths.isEmpty() ) { return foundPaths; } } return null; } @Deprecated  StandardBranchCollisionDetector( Evaluator evaluator );  StandardBranchCollisionDetector( Evaluator evaluator, Predicate<Path> pathPredicate ); @Override @SuppressWarnings( "unchecked" ) Collection<Path> evaluate( TraversalBranch branch, Direction direction );  }### Answer:
@Test void testFilteredPathEvaluation() { final PropertyContainer endNode = mock( Node.class ); final PropertyContainer alternativeEndNode = mock( Node.class ); final Node startNode = mock( Node.class ); Evaluator evaluator = mock( Evaluator.class ); TraversalBranch branch = mock( TraversalBranch.class ); TraversalBranch alternativeBranch = mock( TraversalBranch.class ); when( branch.iterator() ).thenAnswer( new IteratorAnswer( endNode ) ); when( alternativeBranch.iterator() ).thenAnswer( new IteratorAnswer( alternativeEndNode ) ); when( alternativeBranch.startNode() ).thenReturn( startNode ); when( evaluator.evaluate( Mockito.any( Path.class ) ) ).thenReturn( Evaluation.INCLUDE_AND_CONTINUE ); StandardBranchCollisionDetector collisionDetector = new StandardBranchCollisionDetector( evaluator, path -> alternativeEndNode.equals( path.endNode() ) && startNode.equals( path.startNode() ) ); Collection<Path> incoming = collisionDetector.evaluate( branch, Direction.INCOMING ); Collection<Path> outgoing = collisionDetector.evaluate( branch, Direction.OUTGOING ); Collection<Path> alternativeIncoming = collisionDetector.evaluate( alternativeBranch, Direction.INCOMING ); Collection<Path> alternativeOutgoing = collisionDetector.evaluate( alternativeBranch, Direction.OUTGOING ); assertNull( incoming ); assertNull( outgoing ); assertNull( alternativeIncoming ); assertEquals( 1, alternativeOutgoing.size() ); }