### Question:
FileSourceHelper { @SuppressWarnings("StatementWithEmptyBody") public static Optional<byte[]> digest(Path path) { MessageDigest digest = digest(); try (DigestInputStream dis = new DigestInputStream(Files.newInputStream(path), digest)) { byte[] buffer = new byte[FILE_BUFFER_SIZE]; while (dis.read(buffer) != -1) { } return Optional.of(digest.digest()); } catch (FileNotFoundException e) { return Optional.empty(); } catch (IOException e) { throw new ConfigException("Failed to calculate digest for file: " + path, e); } } private  FileSourceHelper(); static Optional<Instant> lastModifiedTime(Path path); static String safeReadContent(Path path); @SuppressWarnings("StatementWithEmptyBody") static Optional<byte[]> digest(Path path); static boolean isModified(Path filePath, byte[] digest); static boolean isModified(Path filePath, Instant stamp); static Optional<DataAndDigest> readDataAndDigest(Path filePath);  }### Answer:
@Test public void testDigestSameContent() throws Exception { File file1 = folder.newFile("test1"); File file2 = folder.newFile("test2"); Files.write(file1.toPath(), "test file".getBytes()); Files.write(file2.toPath(), "test file".getBytes()); assertThat(FileSourceHelper.digest(file1.toPath()).get(), equalTo(FileSourceHelper.digest(file2.toPath()).get())); }
@Test public void testDigestDifferentContent() throws Exception { File file1 = folder.newFile("test1"); File file2 = folder.newFile("test2"); Files.write(file1.toPath(), "test file1".getBytes()); Files.write(file2.toPath(), "test file2".getBytes()); assertThat(FileSourceHelper.digest(file1.toPath()), not(equalTo(FileSourceHelper.digest(file2.toPath())))); }