FolderIndexer { public void indexFolder(final File file) { if (file.canRead()) { if (file.isDirectory()) { processFolder(file); } else { fileIndexer.indexFile(file); } } }  void indexFolder(final File file);  }
@Test public void testIndexFolderWhenFolderExistsShouldIndexFolder() { underTest.indexFolder(folder1); verify(fileIndexer).indexFile(file); }
@Test public void testIndexFolderWhenFolderCannotBeReadShouldDoNothing() { underTest.indexFolder(new File("folder")); verify(fileIndexer, never()).indexFile(file); }
@Test public void testIndexFolderWhenFolderEmptyShouldDoNothing() { given(folder2.canRead()).willReturn(true); given(folder2.isDirectory()).willReturn(true); given(folder2.list()).willReturn(null); underTest.indexFolder(folder2); verify(fileIndexer, never()).indexFile(file); }