use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method does_not_update_type_when_no_issue_admin_permission.
@Test
public void does_not_update_type_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().setType(BUG));
// User has not issue admin permission on these 2 issues
IssueDto notAuthorizedIssue1 = db.issues().insertIssue(newUnresolvedIssue(rule, anotherFile, anotherProject).setType(BUG));
IssueDto notAuthorizedIssue2 = db.issues().insertIssue(newUnresolvedIssue(rule, anotherFile, anotherProject).setType(BUG));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(asList(authorizedIssue1.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).setSetType(VULNERABILITY.name()).build());
checkResponse(response, 3, 1, 2, 0);
assertThat(getIssueByKeys(authorizedIssue1.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).extracting(IssueDto::getKey, IssueDto::getType, IssueDto::getUpdatedAt).containsOnly(tuple(authorizedIssue1.getKey(), VULNERABILITY.getDbConstant(), NOW), tuple(notAuthorizedIssue1.getKey(), BUG.getDbConstant(), notAuthorizedIssue1.getUpdatedAt()), tuple(notAuthorizedIssue2.getKey(), BUG.getDbConstant(), notAuthorizedIssue2.getUpdatedAt()));
}
Aggregations