use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method add_comment_only_on_changed_issues.
@Test
public void add_comment_only_on_changed_issues() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
IssueDto issue1 = db.issues().insertIssue(newUnresolvedIssue().setType(BUG).setSeverity(MINOR));
// These 2 issues will be ignored as there's nothing to do
IssueDto issue2 = db.issues().insertIssue(newUnresolvedIssue().setType(VULNERABILITY));
IssueDto issue3 = db.issues().insertIssue(newUnresolvedIssue().setType(VULNERABILITY));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(asList(issue1.getKey(), issue2.getKey(), issue3.getKey())).setSetType(VULNERABILITY.name()).setComment("test").build());
checkResponse(response, 3, 1, 2, 0);
assertThat(dbClient.issueChangeDao().selectByTypeAndIssueKeys(db.getSession(), singletonList(issue1.getKey()), TYPE_COMMENT)).hasSize(1);
assertThat(dbClient.issueChangeDao().selectByTypeAndIssueKeys(db.getSession(), singletonList(issue2.getKey()), TYPE_COMMENT)).isEmpty();
assertThat(dbClient.issueChangeDao().selectByTypeAndIssueKeys(db.getSession(), singletonList(issue3.getKey()), TYPE_COMMENT)).isEmpty();
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method bulk_change_many_issues.
@Test
public void bulk_change_many_issues() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
UserDto userToAssign = db.users().insertUser("arthur");
IssueDto issue1 = db.issues().insertIssue(newUnresolvedIssue().setAssignee(user.getLogin())).setType(BUG).setSeverity(MINOR);
IssueDto issue2 = db.issues().insertIssue(newUnresolvedIssue().setAssignee(userToAssign.getLogin())).setType(BUG).setSeverity(MAJOR);
IssueDto issue3 = db.issues().insertIssue(newUnresolvedIssue().setAssignee(null)).setType(VULNERABILITY).setSeverity(MAJOR);
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(asList(issue1.getKey(), issue2.getKey(), issue3.getKey())).setAssign(userToAssign.getLogin()).setSetSeverity(MINOR).setSetType(VULNERABILITY.name()).build());
checkResponse(response, 3, 3, 0, 0);
assertThat(getIssueByKeys(issue1.getKey(), issue2.getKey(), issue3.getKey())).extracting(IssueDto::getKey, IssueDto::getAssignee, IssueDto::getType, IssueDto::getSeverity, IssueDto::getUpdatedAt).containsOnly(tuple(issue1.getKey(), userToAssign.getLogin(), VULNERABILITY.getDbConstant(), MINOR, NOW), tuple(issue2.getKey(), userToAssign.getLogin(), VULNERABILITY.getDbConstant(), MINOR, NOW), tuple(issue3.getKey(), userToAssign.getLogin(), VULNERABILITY.getDbConstant(), MINOR, NOW));
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method issues_on_which_user_has_not_browse_permission_are_ignored.
@Test
public void issues_on_which_user_has_not_browse_permission_are_ignored() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
ComponentDto anotherProject = db.components().insertProject();
ComponentDto anotherFile = db.components().insertComponent(newFileDto(anotherProject));
IssueDto authorizedIssue = db.issues().insertIssue(newUnresolvedIssue(rule, file, project).setType(BUG));
// User has not browse 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(authorizedIssue.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).setSetType(VULNERABILITY.name()).build());
checkResponse(response, 1, 1, 0, 0);
assertThat(getIssueByKeys(authorizedIssue.getKey(), notAuthorizedIssue1.getKey(), notAuthorizedIssue2.getKey())).extracting(IssueDto::getKey, IssueDto::getType, IssueDto::getUpdatedAt).containsOnly(tuple(authorizedIssue.getKey(), VULNERABILITY.getDbConstant(), NOW), tuple(notAuthorizedIssue1.getKey(), BUG.getDbConstant(), notAuthorizedIssue1.getUpdatedAt()), tuple(notAuthorizedIssue2.getKey(), BUG.getDbConstant(), notAuthorizedIssue2.getUpdatedAt()));
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method set_type.
@Test
public void set_type() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setType(BUG));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setSetType(RuleType.CODE_SMELL.name()).build());
checkResponse(response, 1, 1, 0, 0);
IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
assertThat(reloaded.getType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant());
assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
use of org.sonarqube.ws.Issues.BulkChangeWsResponse in project sonarqube by SonarSource.
the class BulkChangeActionTest method ignore_issues_when_condition_does_not_match.
@Test
public void ignore_issues_when_condition_does_not_match() throws Exception {
setUserProjectPermissions(USER, ISSUE_ADMIN);
IssueDto issue1 = db.issues().insertIssue(newUnresolvedIssue().setType(BUG));
// These 2 issues will be ignored as they are resolved, changing type is not possible
IssueDto issue2 = db.issues().insertIssue(newResolvedIssue().setType(BUG));
IssueDto issue3 = db.issues().insertIssue(newResolvedIssue().setType(BUG));
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(asList(issue1.getKey(), issue2.getKey(), issue3.getKey())).setSetType(VULNERABILITY.name()).build());
checkResponse(response, 3, 1, 2, 0);
assertThat(getIssueByKeys(issue1.getKey(), issue2.getKey(), issue3.getKey())).extracting(IssueDto::getKey, IssueDto::getType, IssueDto::getUpdatedAt).containsOnly(tuple(issue1.getKey(), VULNERABILITY.getDbConstant(), NOW), tuple(issue3.getKey(), BUG.getDbConstant(), issue2.getUpdatedAt()), tuple(issue2.getKey(), BUG.getDbConstant(), issue3.getUpdatedAt()));
}
Aggregations