public void download(String pluginKey, Version version) {
    Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true);
    if (updateCenter.isPresent()) {
      List<Release> installablePlugins = updateCenter.get().findInstallablePlugins(pluginKey, version);
      checkRequest(!installablePlugins.isEmpty(), "Error while downloading plugin '%s' with version '%s'. No compatible plugin found.", pluginKey, version.getName());
      for (Release release : installablePlugins) {
        try {
          downloadRelease(release);
        } catch (Exception e) {
          String message = String.format("Fail to download the plugin (%s, version %s) from %s (error is : %s)",
            release.getArtifact().getKey(), release.getVersion().getName(), release.getDownloadUrl(), e.getMessage());
          LOG.debug(message, e);
          throw new IllegalStateException(message, e);
        }
      }
    }
  }
@Test
  public void fail_if_no_compatible_plugin_found() {
    assertThatThrownBy(() -> pluginDownloader.download("foo", create("1.0")))
      .isInstanceOf(BadRequestException.class);
  }