public static String computeHashForFile(final String filename) {
    try {
      final byte[] bytes = Files.readAllBytes(Paths.get(filename));

      final StringBuilder builder = new StringBuilder();
      for (final byte b : MessageDigest.getInstance("MD5").digest(bytes)) {
        builder.append(String.format("%02x", b));
      }

      return builder.toString();
    } catch (NoSuchAlgorithmException | IOException e) {
      throw new MigrationException(String.format(
          "Could not compute hash for file '%s': %s", filename, e.getMessage()));
    }
  }
@Test
  public void shouldComputeHashForFile() throws Exception {
    // Given:
    final String filePath = Paths.get(testDir, "test_file.txt").toString();
    givenFileWithContents(filePath, "some text");

    // When:
    final String hash = MigrationsDirectoryUtil.computeHashForFile(filePath);

    // Then:
    assertThat(hash, is("4d93d51945b88325c213640ef59fc50b"));
  }