### Question:
SourceFileTraversal { public void traverse(Visitor visitor) { traverse("", root, visitor); } SourceFileTraversal(File root); void traverse(Visitor visitor);  }### Answer:
@Test public void traverseRootMatch() { File file = mockFile("one.Test"); SourceFileTraversal traversal = new SourceFileTraversal(mockFolder("test", file)); Visitor visitor = mock(Visitor.class); traversal.traverse(visitor); verify(visitor).accept(eq(""), same(file)); verifyNoMoreInteractions(visitor); }
@Test public void traverseMatchWithPath() { File file = mockFile("one.Test"); SourceFileTraversal traversal = new SourceFileTraversal( mockFolder("test", mockFolder("depth1", mockFolder("depth2", file)))); Visitor visitor = mock(Visitor.class); traversal.traverse(visitor); verify(visitor).accept(eq("depth1" + File.separator + "depth2"), same(file)); verifyNoMoreInteractions(visitor); }
@Test public void traverseMatchWithPath() { File file = mockFile("one.Test"); SourceFileTraversal traversal = new SourceFileTraversal(mockFolder("test", mockFolder("depth1", mockFolder("depth2", file)))); Visitor visitor = mock(Visitor.class); traversal.traverse(visitor); verify(visitor).accept(eq("depth1" + File.separator + "depth2"), same(file)); verifyNoMoreInteractions(visitor); }