예제 #1
0
  // SONAR-4602
  @Test
  public void no_issues_mode_cache_after_issue_change() throws Exception {
    restoreProfile("one-issue-per-line.xml");
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator
        .getServer()
        .associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");

    // First run (publish mode)
    SonarRunner runner = configureRunner("shared/xoo-sample");
    orchestrator.executeBuild(runner);

    // First issues mode
    runner = configureRunnerIssues("shared/xoo-sample");
    BuildResult result = orchestrator.executeBuild(runner);

    // 17 issues
    assertThat(ItUtils.countIssuesInJsonReport(result, false)).isEqualTo(17);

    // Flag one issue as false positive
    JSONObject obj = ItUtils.getJSONReport(result);
    String key = ((JSONObject) ((JSONArray) obj.get("issues")).get(0)).get("key").toString();
    orchestrator.getServer().adminWsClient().issueClient().doTransition(key, "falsepositive");

    // Second issues mode
    runner = configureRunnerIssues("shared/xoo-sample");
    result = orchestrator.executeBuild(runner);

    // False positive is not returned
    assertThat(ItUtils.countIssuesInJsonReport(result, false)).isEqualTo(16);
  }
예제 #2
0
  // SONAR-4602
  @Test
  public void no_issues_mode_cache_after_profile_change() throws Exception {
    restoreProfile("one-issue-per-line-empty.xml");
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator
        .getServer()
        .associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");

    // First run (publish mode)
    SonarRunner runner = configureRunner("shared/xoo-sample");
    orchestrator.executeBuild(runner);

    // First issues mode
    runner = configureRunnerIssues("shared/xoo-sample");
    BuildResult result = orchestrator.executeBuild(runner);

    // No new issues
    assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(0);

    // Modification of QP should invalidate cache
    restoreProfile("/one-issue-per-line.xml");

    // Second issues mode
    runner =
        configureRunnerIssues("shared/xoo-sample", "sonar.report.export.path", "sonar-report.json");
    result = orchestrator.executeBuild(runner);

    // As many new issue as lines
    assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
  }
예제 #3
0
  @Test
  public void non_associated_mode() throws IOException {
    restoreProfile("one-issue-per-line.xml");
    setDefaultQualityProfile("xoo", "one-issue-per-line");
    SonarRunner runner = configureRunnerIssues("shared/xoo-sample-non-associated");
    BuildResult result = orchestrator.executeBuild(runner);

    assertThat(result.getLogs()).contains("Local analysis");
    assertThat(result.getLogs()).contains("Cache not found, synchronizing data");
    assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);

    result = orchestrator.executeBuild(runner);
    assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
    assertThat(result.getLogs()).contains("Found cache");
  }
예제 #4
0
 @Test
 public void issues_analysis_on_new_project() throws IOException {
   restoreProfile("one-issue-per-line.xml");
   orchestrator.getServer().provisionProject("sample", "xoo-sample");
   orchestrator
       .getServer()
       .associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
   SonarRunner runner = configureRunnerIssues("shared/xoo-sample", "sonar.verbose", "true");
   BuildResult result = orchestrator.executeBuild(runner);
   assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
 }