Пример #1
0
  /** SONAR-3072 */
  @Test
  public void track_issues_based_on_blocks_recognition() throws Exception {
    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "issue-on-tag-foobar");

    // version 1
    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "issue-on-tag-foobar");
    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);
    Date issueDate = toDate(issues.iterator().next().getCreationDate());

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

    issues = searchUnresolvedIssuesByComponent("sample:src/main/xoo/sample/Sample.xoo");
    assertThat(issues).hasSize(3);

    // issue created during the first scan and moved during the second scan
    assertThat(toDate(getIssueOnLine(6, "xoo:HasTag", issues).getCreationDate()))
        .isEqualTo(issueDate);

    // issues created during the second scan
    assertThat(toDate(getIssueOnLine(10, "xoo:HasTag", issues).getCreationDate()))
        .isAfter(issueDate);
    assertThat(toDate(getIssueOnLine(14, "xoo:HasTag", issues).getCreationDate()))
        .isAfter(issueDate);
  }
Пример #2
0
  @Test
  public void close_issues_on_removed_components() throws Exception {
    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);

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

    issues =
        searchIssues(new SearchWsRequest().setProjectKeys(singletonList("sample"))).getIssuesList();
    assertThat(issues).hasSize(1);
    assertThat(issues.get(0).getStatus()).isEqualTo("CLOSED");
    assertThat(issues.get(0).getResolution()).isEqualTo("FIXED");
  }
Пример #3
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");
  }
Пример #4
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());
    }
  }
Пример #5
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();
  }
Пример #6
0
 @BeforeClass
 public static void scanProject() {
   orchestrator.resetData();
   runProjectAnalysis(orchestrator, "shared/xoo-sample");
 }