Search in sources :

Example 21 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method scan_should_not_reopen_or_close_false_positives.

/**
   * SONAR-4286
   */
@Test
public void scan_should_not_reopen_or_close_false_positives() {
    // user marks issue as false-positive
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "falsepositive"));
    Issue falsePositive = issueRule.getByKey(issue.getKey());
    assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED");
    assertThat(falsePositive.getResolution()).isEqualTo("FALSE-POSITIVE");
    assertThat(falsePositive.getCreationDate()).isEqualTo(issue.getCreationDate());
    // re-execute the same scan
    analysisWithIssues.run();
    // refresh
    Issue reloaded = issueRule.getByKey(falsePositive.getKey());
    assertThat(reloaded.getStatus()).isEqualTo("RESOLVED");
    assertThat(reloaded.getResolution()).isEqualTo("FALSE-POSITIVE");
    assertThat(reloaded.getCreationDate()).isEqualTo(issue.getCreationDate());
// TODO check that update date has not been changed
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Example 22 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method user_should_reopen_false_positive.

/**
   * SONAR-4286
   */
@Test
public void user_should_reopen_false_positive() {
    // user marks as false-positive
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "falsepositive"));
    Issue falsePositive = issueRule.getByKey(issue.getKey());
    assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED");
    assertThat(falsePositive.getResolution()).isEqualTo("FALSE-POSITIVE");
    assertThat(falsePositive.getCreationDate()).isEqualTo(issue.getCreationDate());
    // user reopens the issue
    assertThat(transitions(falsePositive.getKey())).contains("reopen");
    adminIssueClient().doTransition(falsePositive.getKey(), "reopen");
    Issue reopened = issueRule.getByKey(issue.getKey());
    assertThat(reopened.getStatus()).isEqualTo("REOPENED");
    assertThat(reopened.hasResolution()).isFalse();
    assertThat(reopened.getCreationDate()).isEqualTo(falsePositive.getCreationDate());
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Example 23 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method scan_should_reopen_unresolved_issue_but_marked_as_resolved.

/**
   * SONAR-4288
   */
@Test
public void scan_should_reopen_unresolved_issue_but_marked_as_resolved() {
    // mark as resolved
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve"));
    Issue resolvedIssue = issueRule.getByKey(issue.getKey());
    assertThat(resolvedIssue.getStatus()).isEqualTo("RESOLVED");
    assertThat(resolvedIssue.getResolution()).isEqualTo("FIXED");
    assertThat(resolvedIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
    assertThat(toDatetime(resolvedIssue.getUpdateDate())).isAfter(toDatetime(resolvedIssue.getCreationDate()));
    assertThat(toDatetime(resolvedIssue.getUpdateDate())).isAfter(toDatetime(issue.getUpdateDate()));
    // re-execute scan, with the same Q profile -> the issue has not been fixed
    analysisWithIssues.run();
    // reload issue
    Issue reopenedIssue = issueRule.getByKey(issue.getKey());
    // the issue has been reopened
    assertThat(reopenedIssue.getStatus()).isEqualTo("REOPENED");
    assertThat(reopenedIssue.hasResolution()).isFalse();
    assertThat(reopenedIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
    assertThat(toDatetime(reopenedIssue.getUpdateDate())).isAfter(toDatetime(issue.getUpdateDate()));
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Example 24 with Issue

use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.

the class IssueWorkflowTest method user_should_reopen_issue_marked_as_resolved.

/**
   * SONAR-4288
   */
@Test
public void user_should_reopen_issue_marked_as_resolved() {
    // user marks issue as resolved
    issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve"));
    Issue resolved = issueRule.getByKey(issue.getKey());
    assertThat(resolved.getStatus()).isEqualTo("RESOLVED");
    assertThat(resolved.getResolution()).isEqualTo("FIXED");
    assertThat(resolved.getCreationDate()).isEqualTo(issue.getCreationDate());
    // user reopens the issue
    assertThat(transitions(resolved.getKey())).contains("reopen");
    adminIssueClient().doTransition(resolved.getKey(), "reopen");
    Issue reopened = issueRule.getByKey(resolved.getKey());
    assertThat(reopened.getStatus()).isEqualTo("REOPENED");
    assertThat(reopened.hasResolution()).isFalse();
    assertThat(reopened.getCreationDate()).isEqualTo(resolved.getCreationDate());
    assertThat(toDatetime(reopened.getUpdateDate())).isAfterOrEqualsTo(toDatetime(resolved.getUpdateDate()));
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) DoTransitionRequest(org.sonarqube.ws.client.issue.DoTransitionRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)24 Issue (org.sonarqube.ws.Issues.Issue)24 DoTransitionRequest (org.sonarqube.ws.client.issue.DoTransitionRequest)9 Issues (org.sonarqube.ws.Issues)5 AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)5 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)4 SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)4 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)2 SetSeverityRequest (org.sonarqube.ws.client.issue.SetSeverityRequest)2 Collections.singletonList (java.util.Collections.singletonList)1 Date (java.util.Date)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 ClassRule (org.junit.ClassRule)1 Rule (org.junit.Rule)1 BLOCKER (org.sonarqube.ws.Common.Severity.BLOCKER)1 AssignRequest (org.sonarqube.ws.client.issue.AssignRequest)1 IssuesService (org.sonarqube.ws.client.issue.IssuesService)1