Ejemplo n.º 1
0
  @Test
  public void verify_properties_displayed_in_json_per_installing_plugin() throws Exception {
    when(pluginDownloader.getDownloadedPlugins()).thenReturn(of(gitPluginInfo()));
    UpdateCenter updateCenter = mock(UpdateCenter.class);
    when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
    when(updateCenter.findAllCompatiblePlugins())
        .thenReturn(Arrays.asList(new Plugin("scmgit").setCategory("cat_1")));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .isSimilarTo(
            "{"
                + "  \"installing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"scmgit\","
                + "      \"name\": \"Git\","
                + "      \"description\": \"Git SCM Provider.\","
                + "      \"version\": \"1.0\","
                + "      \"license\": \"GNU LGPL 3\","
                + "      \"category\":\"cat_1\","
                + "      \"organizationName\": \"SonarSource\","
                + "      \"organizationUrl\": \"http://www.sonarsource.com\","
                + "      \"homepageUrl\": \"http://redirect.sonarsource.com/plugins/scmgit.html\","
                + "      \"issueTrackerUrl\": \"http://jira.sonarsource.com/browse/SONARSCGIT\","
                + "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\""
                + "    }"
                + "  ],"
                + "  \"removing\": []"
                + "}");
  }
Ejemplo n.º 2
0
 private Collection<PluginUpdateAggregate> retrieveUpdatablePlugins(UpdateCenter updateCenter) {
   List<PluginUpdate> pluginUpdates = updateCenter.findPluginUpdates();
   // aggregates updates of the same plugin to a single object and sort these objects by plugin
   // name then key
   return ImmutableSortedSet.copyOf(
       NAME_KEY_PLUGIN_UPGRADE_AGGREGATE_ORDERING, aggregator.aggregate(pluginUpdates));
 }
Ejemplo n.º 3
0
  @Test
  public void if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter()
      throws Exception {
    Version version = Version.create("1.0");
    when(updateCenter.findPluginUpdates())
        .thenReturn(
            ImmutableList.of(
                PluginUpdate.createWithStatus(
                    new Release(new Plugin(PLUGIN_KEY), version), Status.COMPATIBLE)));

    underTest.handle(validRequest, response);

    verify(pluginDownloader).download(PLUGIN_KEY, version);
    assertThat(response.outputAsString()).isEmpty();
  }