public Optional<File> get(InstalledPlugin plugin) {
    // Does not fail if another process tries to create the directory at the same time.
    Path jarInCache = jarInCache(plugin.key, plugin.hash);
    if (Files.isRegularFile(jarInCache)) {
      return Optional.of(jarInCache.toFile());
    }
    return download(plugin).map(Path::toFile);
  }
@Test
  void fail_if_integrity_of_download_is_not_valid() throws IOException {
    FileAndMd5 tempJar = new FileAndMd5();
    stubDownload(tempJar.file, "invalid_hash");
    InstalledPlugin plugin = newInstalledPlugin("foo", "abc");

    expectISE("foo", "was expected to have checksum invalid_hash but had " + tempJar.md5,
      () -> underTest.get(plugin));
  }