Search in sources :

Example 11 with BulkChangeWsResponse

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

the class IssueBulkChangeTest method should_setSeverity_add_comment_in_single_WS_call.

@Test
public void should_setSeverity_add_comment_in_single_WS_call() {
    xooSampleLittleIssuesAnalysis.run();
    String newSeverity = "BLOCKER";
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setSetSeverity(newSeverity).setComment(COMMENT_AS_MARKDOWN).build());
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    for (Issue issue : issueRule.getByKeys(issueKeys)) {
        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 12 with BulkChangeWsResponse

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

the class IssueBulkChangeTest method should_add_comment_only_on_issues_that_will_be_changed.

@Test
public void should_add_comment_only_on_issues_that_will_be_changed() {
    xooSampleLittleIssuesAnalysis.run();
    int nbIssues = BULK_EDITED_ISSUE_COUNT;
    String[] issueKeys = searchIssueKeys(nbIssues);
    // Confirm an issue
    adminIssueClient().doTransition(searchIssues().iterator().next().key(), "confirm");
    // Apply a bulk change on unconfirm transition
    BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setDoTransition("unconfirm").setComment("this is my comment").build());
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(1);
    int nbIssuesWithComment = 0;
    for (Issues.Issue issue : issueRule.getByKeys(issueKeys)) {
        if (!issue.getComments().getCommentsList().isEmpty()) {
            nbIssuesWithComment++;
        }
    }
    // Only one issue should have the comment
    assertThat(nbIssuesWithComment).isEqualTo(1);
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) Issues(org.sonarqube.ws.Issues) BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 13 with BulkChangeWsResponse

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

the class IssueBulkChangeTest method should_not_apply_bulk_change_if_no_change_to_do.

@Test
public void should_not_apply_bulk_change_if_no_change_to_do() {
    xooSampleLittleIssuesAnalysis.run();
    String newSeverity = "BLOCKER";
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    // Apply the bulk change a first time
    BulkChangeWsResponse bulkChangeResponse = bulkChangeSeverityOfIssues(issueKeys, newSeverity);
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    // Re apply the same bulk change -> no issue should be changed
    bulkChangeResponse = bulkChangeSeverityOfIssues(issueKeys, newSeverity);
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(0);
    assertThat(bulkChangeResponse.getIgnored()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
}
Also used : BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 14 with BulkChangeWsResponse

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

the class IssueBulkChangeTest method should_do_transition.

@Test
public void should_do_transition() {
    xooSampleLittleIssuesAnalysis.run();
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    BulkChangeWsResponse bulkChangeResponse = bulkTransitionStatusOfIssues(issueKeys, "confirm");
    assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    assertIssueStatus(issueKeys, "CONFIRMED");
}
Also used : BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 15 with BulkChangeWsResponse

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

the class IssueBulkChangeTest method should_change_severity.

@Test
public void should_change_severity() {
    xooSampleLittleIssuesAnalysis.run();
    String newSeverity = "BLOCKER";
    String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT);
    BulkChangeWsResponse bulkChange = bulkChangeSeverityOfIssues(issueKeys, newSeverity);
    assertThat(bulkChange.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
    assertIssueSeverity(issueKeys, newSeverity);
}
Also used : BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)21 IssueDto (org.sonar.db.issue.IssueDto)14 Issue (org.sonarqube.ws.Issues.Issue)4 ComponentDto (org.sonar.db.component.ComponentDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)2 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)1 UserDto (org.sonar.db.user.UserDto)1 Issues (org.sonarqube.ws.Issues)1