コード例 #1
0
  /** SONAR-4310 */
  @Test
  public void track_existing_unchanged_issues_on_multi_modules() throws Exception {
    // The custom rule on module is enabled
    ORCHESTRATOR
        .getServer()
        .provisionProject(
            "com.sonarsource.it.samples:multi-modules-sample",
            "com.sonarsource.it.samples:multi-modules-sample");
    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(
            "com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");

    // One issue by module are created
    List<Issue> issues = searchIssues(new SearchWsRequest()).getIssuesList();
    assertThat(issues).hasSize(4);

    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");

    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(issues.size());

    // Issues on modules should stay open and be the same from the first analysis
    for (Issue issue : issues) {
      Issue reloadIssue = getIssueByKey(issue.getKey());
      assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
      assertThat(reloadIssue.hasResolution()).isFalse();
      assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
      assertThat(reloadIssue.getUpdateDate()).isEqualTo(issue.getUpdateDate());
    }
  }
コード例 #2
0
  @Test
  public void track_file_moves_based_on_identical_content() {
    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "issue-on-tag-foobar");

    // version 1
    runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v1", "sonar.projectDate", OLD_DATE);

    List<Issue> issues = searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample.xoo");
    assertThat(issues).hasSize(1);
    Issue issueOnSample = issues.iterator().next();

    // version 2
    runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v3", "sonar.projectDate", NEW_DATE_STR);

    assertThat(searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample.xoo"))
        .isEmpty();

    issues = searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample2.xoo");
    assertThat(issues).hasSize(1);
    Issue issueOnSample2 = issues.get(0);
    assertThat(issueOnSample2.getKey()).isEqualTo(issueOnSample.getKey());
    assertThat(issueOnSample2.getCreationDate()).isEqualTo(issueOnSample.getCreationDate());
    assertThat(issueOnSample2.getUpdateDate()).isNotEqualTo(issueOnSample.getUpdateDate());
    assertThat(issueOnSample2.getStatus()).isEqualTo("OPEN");
  }
コード例 #3
0
  /** SONAR-4310 */
  @Test
  public void track_existing_unchanged_issues_on_module() throws Exception {
    // The custom rule on module is enabled

    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");

    // Only one issue is created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);
    Issue issue = getRandomIssue();

    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");

    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);

    // The issue on module should stay open and be the same from the first analysis
    Issue reloadIssue = getIssueByKey(issue.getKey());
    assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
    assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
    assertThat(reloadIssue.hasResolution()).isFalse();
  }