TaildirMatcher { private List<File> getMatchingFilesNoCache() { List<File> result = Lists.newArrayList(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(parentDir.toPath(), fileFilter)) { for (Path entry : stream) { result.add(entry.toFile()); } } catch (IOException e) { logger.error("I/O exception occurred while listing parent directory. " + "Files already matched will be returned. " + parentDir.toPath(), e); } return result; } TaildirMatcher(String fileGroup, String filePattern, boolean cachePatternMatching); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); String getFileGroup();  }
@Test public void getMatchingFilesNoCache() throws Exception { append("file0"); append("file1"); TaildirMatcher tm = new TaildirMatcher("f1", tmpDir.getAbsolutePath() + File.separator + "file.*", false); List<String> files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAlreadyExistingFile, 2, files.size()); assertTrue(msgAlreadyExistingFile, files.contains("file1")); append("file1"); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterAppend, 2, files.size()); assertTrue(msgAfterAppend, files.contains("file0")); assertTrue(msgAfterAppend, files.contains("file1")); append("file2"); append("file3"); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterNewFileCreated, 4, files.size()); assertTrue(msgAfterNewFileCreated, files.contains("file0")); assertTrue(msgAfterNewFileCreated, files.contains("file1")); assertTrue(msgAfterNewFileCreated, files.contains("file2")); assertTrue(msgAfterNewFileCreated, files.contains("file3")); this.files.get("file0").delete(); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterDelete, 3, files.size()); assertFalse(msgAfterDelete, files.contains("file0")); assertTrue(msgNoChange, files.contains("file1")); assertTrue(msgNoChange, files.contains("file2")); assertTrue(msgNoChange, files.contains("file3")); }