@Test public void test_analyzeFiles__nested_folders() throws FileNotFoundException { String rootPath = path + "test_nested/"; File rootFolder = new File(rootPath); List<File> roots = new LinkedList<>(); roots.add(rootFolder); List<MarkerPair> pairs = getMarkers(); List<MarkerPair> pairs2 = getMarkers(); String markedFile = rootPath + "test_pair.txt"; String markedFile2 = rootPath + "other/test_pair.txt"; Map<String, List<MarkerPair>> expectedResult = new HashMap<>(); expectedResult.put(markedFile, pairs); expectedResult.put(markedFile2, pairs2); Map<String, List<MarkerPair>> actualResult = processor.analyzeFiles(roots); assertThat(actualResult, is(expectedResult)); }
protected Map<String, List<MarkerPair>> analyzeFiles(List<File> rootFiles) { Set<File> files = new HashSet<>(); for (File rootFile : rootFiles) { Set<File> filesUnderRoot = getFiles(rootFile, new HashSet<>()); files.addAll(filesUnderRoot); } Map<String, List<MarkerPair>> result = new HashMap<>(); for (File file : files) { try { LOG.debug("Analyzing: {}", file.getPath()); List<MarkerPair> markerPairs = fileProcessor.processFile(file); if (!markerPairs.isEmpty()) { result.put(file.getPath(), markerPairs); } } catch (FileNotFoundException e) { LOG.error("File not found:{}", file.getAbsolutePath(), e); } catch (IOException e) { LOG.error("Was not able to process file:{}", file.getAbsolutePath(), e); } } return result; }
Analyzer { protected Map<String, List<MarkerPair>> analyzeFiles(List<File> rootFiles) { Set<File> files = new HashSet<>(); for (File rootFile : rootFiles) { Set<File> filesUnderRoot = getFiles(rootFile, new HashSet<>()); files.addAll(filesUnderRoot); } Map<String, List<MarkerPair>> result = new HashMap<>(); for (File file : files) { try { LOG.debug("Analyzing: {}", file.getPath()); List<MarkerPair> markerPairs = fileProcessor.processFile(file); if (!markerPairs.isEmpty()) { result.put(file.getPath(), markerPairs); } } catch (FileNotFoundException e) { LOG.error("File not found:{}", file.getAbsolutePath(), e); } catch (IOException e) { LOG.error("Was not able to process file:{}", file.getAbsolutePath(), e); } } return result; } }
Analyzer { protected Map<String, List<MarkerPair>> analyzeFiles(List<File> rootFiles) { Set<File> files = new HashSet<>(); for (File rootFile : rootFiles) { Set<File> filesUnderRoot = getFiles(rootFile, new HashSet<>()); files.addAll(filesUnderRoot); } Map<String, List<MarkerPair>> result = new HashMap<>(); for (File file : files) { try { LOG.debug("Analyzing: {}", file.getPath()); List<MarkerPair> markerPairs = fileProcessor.processFile(file); if (!markerPairs.isEmpty()) { result.put(file.getPath(), markerPairs); } } catch (FileNotFoundException e) { LOG.error("File not found:{}", file.getAbsolutePath(), e); } catch (IOException e) { LOG.error("Was not able to process file:{}", file.getAbsolutePath(), e); } } return result; }  }
Analyzer { protected Map<String, List<MarkerPair>> analyzeFiles(List<File> rootFiles) { Set<File> files = new HashSet<>(); for (File rootFile : rootFiles) { Set<File> filesUnderRoot = getFiles(rootFile, new HashSet<>()); files.addAll(filesUnderRoot); } Map<String, List<MarkerPair>> result = new HashMap<>(); for (File file : files) { try { LOG.debug("Analyzing: {}", file.getPath()); List<MarkerPair> markerPairs = fileProcessor.processFile(file); if (!markerPairs.isEmpty()) { result.put(file.getPath(), markerPairs); } } catch (FileNotFoundException e) { LOG.error("File not found:{}", file.getAbsolutePath(), e); } catch (IOException e) { LOG.error("Was not able to process file:{}", file.getAbsolutePath(), e); } } return result; }  AnalyzerResult analyze(List<String> filePaths); }
Analyzer { protected Map<String, List<MarkerPair>> analyzeFiles(List<File> rootFiles) { Set<File> files = new HashSet<>(); for (File rootFile : rootFiles) { Set<File> filesUnderRoot = getFiles(rootFile, new HashSet<>()); files.addAll(filesUnderRoot); } Map<String, List<MarkerPair>> result = new HashMap<>(); for (File file : files) { try { LOG.debug("Analyzing: {}", file.getPath()); List<MarkerPair> markerPairs = fileProcessor.processFile(file); if (!markerPairs.isEmpty()) { result.put(file.getPath(), markerPairs); } } catch (FileNotFoundException e) { LOG.error("File not found:{}", file.getAbsolutePath(), e); } catch (IOException e) { LOG.error("Was not able to process file:{}", file.getAbsolutePath(), e); } } return result; }  AnalyzerResult analyze(List<String> filePaths);  }