コード例 #1
0
ファイル: PendingActionTest.java プロジェクト: ihr/sonarqube
  @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\": []"
                + "}");
  }
コード例 #2
0
ファイル: PendingActionTest.java プロジェクト: ihr/sonarqube
  @Test
  public void removing_plugins_are_sorted_and_unique() throws Exception {
    when(serverPluginRepository.getUninstalledPlugins())
        .thenReturn(
            of(
                newPluginInfo(0).setName("Foo"),
                newPluginInfo(3).setName("Bar"),
                newPluginInfo(2).setName("Bar")));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo(
            "{"
                + "  \"installing\": [],"
                + "  \"removing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"key2\","
                + "      \"name\": \"Bar\","
                + "    },"
                + "    {"
                + "      \"key\": \"key3\","
                + "      \"name\": \"Bar\","
                + "    },"
                + "    {"
                + "      \"key\": \"key0\","
                + "      \"name\": \"Foo\","
                + "    }"
                + "  ]"
                + "}");
  }
コード例 #3
0
ファイル: PendingActionTest.java プロジェクト: ihr/sonarqube
  @Test
  public void verify_properties_displayed_in_json_per_removing_plugin() throws Exception {
    when(serverPluginRepository.getUninstalledPlugins()).thenReturn(of(gitPluginInfo()));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .isSimilarTo(
            "{"
                + "  \"installing\": [],"
                + "  \"removing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"scmgit\","
                + "      \"name\": \"Git\","
                + "      \"description\": \"Git SCM Provider.\","
                + "      \"version\": \"1.0\","
                + "      \"license\": \"GNU LGPL 3\","
                + "      \"organizationName\": \"SonarSource\","
                + "      \"organizationUrl\": \"http://www.sonarsource.com\","
                + "      \"homepageUrl\": \"http://redirect.sonarsource.com/plugins/scmgit.html\","
                + "      \"issueTrackerUrl\": \"http://jira.sonarsource.com/browse/SONARSCGIT\","
                + "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\""
                + "    }"
                + "  ]"
                + "}");
  }
コード例 #4
0
ファイル: PendingActionTest.java プロジェクト: ihr/sonarqube
  @Test
  public void empty_arrays_are_returned_when_there_nothing_pending() throws Exception {
    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo("{" + "  \"installing\": []," + "  \"removing\": []" + "}");
  }
コード例 #5
0
ファイル: PendingActionTest.java プロジェクト: ihr/sonarqube
  @Test
  public void empty_arrays_are_returned_when_update_center_is_unavailable() throws Exception {
    when(updateCenterMatrixFactory.getUpdateCenter(false))
        .thenReturn(Optional.<UpdateCenter>absent());

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo("{" + "  \"installing\": []," + "  \"removing\": []" + "}");
  }
コード例 #6
0
ファイル: UpdateActionTest.java プロジェクト: hutea/sonarqube
  @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();
  }