@Test public void directoryHasChanged_returnsTrueForNewFileInDirectory() throws Exception { File checksumFile = tempFolder.newFile("checksums.csv"); Map<String, String> checksums = initialiseChecksumFile(checksumFile, 3); String existingDirPath = checksums.keySet().iterator().next(); File tmpFile = new File(existingDirPath, "newFile.txt"); try (final PrintWriter pw = new PrintWriter(new FileWriter(tmpFile))) { pw.println("Blah"); } FileUpdateChecker checker = new FileUpdateChecker(checksumFile.getAbsolutePath()); assertTrue(checker.directoryHasChanged(existingDirPath)); }
public boolean directoryHasChanged(String directoryPath) throws IOException { boolean ret = true; String dirHash = hashDirectory(directoryPath, true); if (checksums.containsKey(directoryPath)) { ret = !checksums.get(directoryPath).equals(dirHash); } checksums.put(directoryPath, dirHash); return ret; }
FileUpdateChecker { public boolean directoryHasChanged(String directoryPath) throws IOException { boolean ret = true; String dirHash = hashDirectory(directoryPath, true); if (checksums.containsKey(directoryPath)) { ret = !checksums.get(directoryPath).equals(dirHash); } checksums.put(directoryPath, dirHash); return ret; } }
FileUpdateChecker { public boolean directoryHasChanged(String directoryPath) throws IOException { boolean ret = true; String dirHash = hashDirectory(directoryPath, true); if (checksums.containsKey(directoryPath)) { ret = !checksums.get(directoryPath).equals(dirHash); } checksums.put(directoryPath, dirHash); return ret; } FileUpdateChecker(String checksumFilepath); }
FileUpdateChecker { public boolean directoryHasChanged(String directoryPath) throws IOException { boolean ret = true; String dirHash = hashDirectory(directoryPath, true); if (checksums.containsKey(directoryPath)) { ret = !checksums.get(directoryPath).equals(dirHash); } checksums.put(directoryPath, dirHash); return ret; } FileUpdateChecker(String checksumFilepath); boolean directoryHasChanged(String directoryPath); void writeChecksums(); }
FileUpdateChecker { public boolean directoryHasChanged(String directoryPath) throws IOException { boolean ret = true; String dirHash = hashDirectory(directoryPath, true); if (checksums.containsKey(directoryPath)) { ret = !checksums.get(directoryPath).equals(dirHash); } checksums.put(directoryPath, dirHash); return ret; } FileUpdateChecker(String checksumFilepath); boolean directoryHasChanged(String directoryPath); void writeChecksums();  }