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);
}
}
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);
}
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);
}
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");
}
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);
}
Aggregations