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 getPlugin_whenTimeOutReached_thenDownloadFails() {
    sonarqube.stubFor(get(anyUrl())
      .willReturn(ok()
        .withFixedDelay(5000)));

    InstalledPlugin plugin = newInstalledPlugin("foo", "abc");

    assertThatThrownBy(() -> underTest.get(plugin))
      .isInstanceOf(IllegalStateException.class)
      .hasMessageStartingWith("Fail to request url")
      .cause().isInstanceOf(SocketTimeoutException.class);
  }