Search in sources :

Example 6 with Issue

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

the class IssueBulkChangeTest method should_apply_bulk_change_on_many_actions.

@Test
public void should_apply_bulk_change_on_many_actions() {
    xooSampleLittleIssuesAnalysis.run();
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setDoTransition("confirm").setAssign("admin").setSetSeverity("BLOCKER").setComment(COMMENT_AS_MARKDOWN).build());
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    for (Issue issue : issueRule.getByKeys(issueKeys)) {
        assertThat(issue.getStatus()).isEqualTo("CONFIRMED");
        assertThat(issue.getAssignee()).isEqualTo("admin");
        assertThat(issue.getSeverity()).isEqualTo(BLOCKER);
        assertThat(issue.getComments().getCommentsList()).hasSize(1);
        assertThat(issue.getComments().getComments(0).getHtmlText()).isEqualTo(COMMENT_AS_HTML);
    }
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 7 with Issue

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

the class IssueBulkChangeTest method should_assign.

@Test
public void should_assign() {
    xooSampleLittleIssuesAnalysis.run();
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    BulkChangeWsResponse bulkChangeResponse = buldChangeAssigneeOfIssues(issueKeys, "admin");
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    for (Issue issue : issueRule.getByKeys(issueKeys)) {
        assertThat(issue.getAssignee()).isEqualTo("admin");
    }
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 8 with Issue

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

the class IssueTrackingTest method track_issues_based_on_blocks_recognition.

/**
   * 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);
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) Date(java.util.Date) ItUtils.toDate(util.ItUtils.toDate) Test(org.junit.Test)

Example 9 with Issue

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

the class IssueTrackingTest method track_existing_unchanged_issues_on_module.

/**
   * 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();
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 10 with Issue

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

the class IssueWorkflowTest method scan_should_close_no_more_existing_false_positive.

/**
   * SONAR-4286
   */
@Test
public void scan_should_close_no_more_existing_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());
    // scan without any rules -> false-positive is closed
    analysisWithoutIssues.run();
    Issue closed = issueRule.getByKey(issue.getKey());
    assertThat(closed.getStatus()).isEqualTo("CLOSED");
    assertThat(closed.getResolution()).isEqualTo("REMOVED");
    assertThat(closed.getCreationDate()).isEqualTo(issue.getCreationDate());
}
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