Search in sources :

Example 21 with BulkChangeWsResponse

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()));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) 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