Ejemplo n.º 1
0
 @Before
 public void resetData() {
   xooSampleAnalysis =
       projectAnalysisRule
           .newProjectAnalysis(projectAnalysisRule.registerProject("shared/xoo-sample"))
           .withQualityProfile(
               projectAnalysisRule.registerProfile(
                   "/issue/IssueChangelogTest/one-issue-per-line-profile.xml"));
   xooSampleAnalysis.run();
   issue = searchRandomIssue();
 }
Ejemplo n.º 2
0
  @Test
  public void update_changelog_when_reopening_unresolved_issue_by_scan() throws Exception {
    assertIssueHasNoChange(issue.key());

    // re analyse the project after resolving an issue in order to reopen it
    adminIssueClient().doTransition(issue.key(), "resolve");
    xooSampleAnalysis.run();

    List<IssueChange> changes = retrieveChangeForIssue(issue.key());
    assertThat(changes).hasSize(2);

    // Change done by the user (first change is be the oldest one)
    IssueChange change1 = changes.get(0);
    assertThat(change1.user()).isEqualTo("admin");
    assertThat(change1.creationDate()).isNotNull();
    assertThat(change1.diffs()).hasSize(2);

    IssueChangeDiff change1Diff1 = change1.diffs().get(0);
    assertThat(change1Diff1.key()).isEqualTo("resolution");
    assertThat(change1Diff1.oldValue()).isNull();
    assertThat(change1Diff1.newValue()).isEqualTo("FIXED");

    IssueChangeDiff change1Diff2 = change1.diffs().get(1);
    assertThat(change1Diff2.key()).isEqualTo("status");
    assertThat(change1Diff2.oldValue()).isEqualTo("OPEN");
    assertThat(change1Diff2.newValue()).isEqualTo("RESOLVED");

    // Change done by scan
    IssueChange change2 = changes.get(1);
    assertThat(change2.user()).isNull();
    assertThat(change2.creationDate()).isNotNull();
    assertThat(change2.diffs()).hasSize(2);

    IssueChangeDiff changeDiff1 = change2.diffs().get(0);
    assertThat(changeDiff1.key()).isEqualTo("resolution");
    assertThat(changeDiff1.oldValue()).isNull();
    assertThat(changeDiff1.newValue()).isNull();

    IssueChangeDiff changeDiff2 = change2.diffs().get(1);
    assertThat(changeDiff2.key()).isEqualTo("status");
    assertThat(changeDiff2.oldValue()).isEqualTo("RESOLVED");
    assertThat(changeDiff2.newValue()).isEqualTo("REOPENED");
  }
Ejemplo n.º 3
0
  /** SONAR-4352 */
  @Test
  public void change_severity() {
    String componentKey = "sample";

    // there are no blocker issues
    assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).isEmpty();

    // increase the severity of an issue
    adminIssueClient().setSeverity(issue.key(), "BLOCKER");

    assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).hasSize(1);

    projectAnalysis.run();
    Issue reloaded = searchIssueByKey(issue.key());
    assertThat(reloaded.severity()).isEqualTo("BLOCKER");
    assertThat(reloaded.status()).isEqualTo("OPEN");
    assertThat(reloaded.resolution()).isNull();
    assertThat(reloaded.creationDate()).isEqualTo(issue.creationDate());
    assertThat(reloaded.creationDate().before(reloaded.updateDate())).isTrue();
  }
Ejemplo n.º 4
0
  /** SONAR-4287 */
  @Test
  public void assign() {
    assertThat(issue.assignee()).isNull();
    Issues issues = search(IssueQuery.create().issues(issue.key()));
    assertThat(issues.users()).isEmpty();

    adminIssueClient().assign(issue.key(), "admin");
    Assertions.assertThat(searchIssues(IssueQuery.create().assignees("admin"))).hasSize(1);

    projectAnalysis.run();
    Issue reloaded = searchIssueByKey(issue.key());
    assertThat(reloaded.assignee()).isEqualTo("admin");
    assertThat(reloaded.creationDate()).isEqualTo(issue.creationDate());

    issues = search(IssueQuery.create().issues(issue.key()));
    assertThat(issues.user("admin")).isNotNull();
    assertThat(issues.user("admin").name()).isEqualTo("Administrator");

    // unassign
    adminIssueClient().assign(issue.key(), null);
    reloaded = searchIssueByKey(issue.key());
    assertThat(reloaded.assignee()).isNull();
    Assertions.assertThat(searchIssues(IssueQuery.create().assignees("admin"))).isEmpty();
  }