use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class BulkChangeActionTest method ignore_issues_when_there_is_nothing_to_do.
@Test
public void ignore_issues_when_there_is_nothing_to_do() 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()).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(issue2.getKey(), VULNERABILITY.getDbConstant(), issue2.getUpdatedAt()), tuple(issue3.getKey(), VULNERABILITY.getDbConstant(), issue3.getUpdatedAt()));
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class BulkChangeActionTest method send_notification.
@Test
public void send_notification() throws Exception {
setUserProjectPermissions(USER);
IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setType(BUG));
ArgumentCaptor<IssueChangeNotification> issueChangeNotificationCaptor = ArgumentCaptor.forClass(IssueChangeNotification.class);
BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setDoTransition("confirm").setSendNotifications(true).build());
checkResponse(response, 1, 1, 0, 0);
verify(notificationManager).scheduleForSending(issueChangeNotificationCaptor.capture());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("key")).isEqualTo(issueDto.getKey());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("componentName")).isEqualTo(file.longName());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("projectName")).isEqualTo(project.longName());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("projectKey")).isEqualTo(project.key());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("ruleName")).isEqualTo(rule.getName());
assertThat(issueChangeNotificationCaptor.getValue().getFieldValue("changeAuthor")).isEqualTo(user.getLogin());
}
use of org.sonar.db.issue.IssueDto 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.sonar.db.issue.IssueDto 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.sonar.db.issue.IssueDto 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");
}
Aggregations