use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method set_severity.
@Test
public void set_severity() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setSeverity(MAJOR));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setSetSeverity(MINOR).build());
checkResponse(response, 1, 1, 0, 0);
IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
assertThat(reloaded.getSeverity()).isEqualTo(MINOR);
assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method does_not_update_severity_when_no_issue_admin_permission.
@Test
public void does_not_update_severity_when_no_issue_admin_permission() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
ComponentDto anotherProject = db.components().insertProject();
ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject));
addUserProjectPermissions(anotherProject, USER);
IssueDto authorizedIssue1 = db.issues().insertIssue(newUnresolvedIssue().setSeverity(MAJOR));
// User has not issue admin permission on these 2 issues
IssueDto notAuthorizedIssue1 = db.issues().insertIssue(newUnresolvedIssue(rule, anotherFile, anotherProject).setSeverity(MAJOR));
IssueDto notAuthorizedIssue2 = db.issues().insertIssue(newUnresolvedIssue(rule, anotherFile, anotherProject).setSeverity(MAJOR));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(asList(authorizedIssue1.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).setSetSeverity(MINOR).build());
checkResponse(response, 3, 1, 2, 0);
assertThat(getIssueByKeys(authorizedIssue1.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).extracting(IssueDto::getKey, IssueDto::getSeverity, IssueDto::getUpdatedAt).containsOnly(tuple(authorizedIssue1.getKey(), MINOR, NOW), tuple(notAuthorizedIssue1.getKey(), MAJOR, notAuthorizedIssue1.getUpdatedAt()), tuple(notAuthorizedIssue2.getKey(), MAJOR, notAuthorizedIssue2.getUpdatedAt()));
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method bulk_change_with_comment.
@Test
public void bulk_change_with_comment() throws Exception {
setUserProjectPermissions(USER);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setType(BUG));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setDoTransition("confirm").setComment("type was badly defined").build());
checkResponse(response, 1, 1, 0, 0);
IssueChangeDto issueComment = dbClient.issueChangeDao().selectByTypeAndIssueKeys(db.getSession(), singletonList(issueDto.getKey()), TYPE_COMMENT).get(0);
assertThat(issueComment.getUserLogin()).isEqualTo("john");
assertThat(issueComment.getChangeData()).isEqualTo("type was badly defined");
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method remove_assignee.
@Test
public void remove_assignee() throws Exception {
setUserProjectPermissions(USER);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setAssignee("arthur"));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setAssign("").build());
checkResponse(response, 1, 1, 0, 0);
IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
assertThat(reloaded.getAssignee()).isNull();
assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method add_tags.
@Test
public void add_tags() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setTags(asList("tag1", "tag2")));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setAddTags(singletonList("tag3")).build());
checkResponse(response, 1, 1, 0, 0);
IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
assertThat(reloaded.getTags()).containsOnly("tag1", "tag2", "tag3");
assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
Aggregations