@Test public void test_getFiles__nested_directory() { File root = new File(path + "test_nested/"); File file = new File(path + "test_nested/test_pair.txt"); File file2 = new File(path + "test_nested/other/test_pair.txt"); Set<File> expectedFiles = new HashSet<>(); expectedFiles.add(file); expectedFiles.add(file2); Set<File> files = new HashSet<>(); Set<File> actualFiles = processor.getFiles(root, files); assertThat(actualFiles, is(expectedFiles)); }
protected Set<File> getFiles(File file, Set<File> files) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { File[] filesInFolder = file.listFiles(); for (File fileInFolder : filesInFolder) { getFiles(fileInFolder, files); } } return files; }
Analyzer { protected Set<File> getFiles(File file, Set<File> files) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { File[] filesInFolder = file.listFiles(); for (File fileInFolder : filesInFolder) { getFiles(fileInFolder, files); } } return files; } }
Analyzer { protected Set<File> getFiles(File file, Set<File> files) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { File[] filesInFolder = file.listFiles(); for (File fileInFolder : filesInFolder) { getFiles(fileInFolder, files); } } return files; }  }
Analyzer { protected Set<File> getFiles(File file, Set<File> files) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { File[] filesInFolder = file.listFiles(); for (File fileInFolder : filesInFolder) { getFiles(fileInFolder, files); } } return files; }  AnalyzerResult analyze(List<String> filePaths); }
Analyzer { protected Set<File> getFiles(File file, Set<File> files) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { File[] filesInFolder = file.listFiles(); for (File fileInFolder : filesInFolder) { getFiles(fileInFolder, files); } } return files; }  AnalyzerResult analyze(List<String> filePaths);  }