use of org.sonar.db.issue.IssueChangeDto 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.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class DeleteCommentActionTest method delete_comment_using_deprecated_key_parameter.
@Test
public void delete_comment_using_deprecated_key_parameter() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
tester.newRequest().setParam("key", commentDto.getKey()).setParam("text", "please have a look").execute();
verify(responseWriter).write(eq(issueDto.getKey()), any(Request.class), any(Response.class));
assertThat(dbClient.issueChangeDao().selectCommentByKey(dbTester.getSession(), commentDto.getKey())).isNotPresent();
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class DeleteCommentActionTest method fail_when_not_enough_permission.
@Test
public void fail_when_not_enough_permission() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
userSession.logIn("john").addProjectUuidPermissions(CODEVIEWER, issueDto.getProjectUuid());
expectedException.expect(ForbiddenException.class);
call(commentDto.getKey());
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class DeleteCommentActionTest method fail_when_comment_has_not_user.
@Test
public void fail_when_comment_has_not_user() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, null, "please fix it");
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("You can only delete your own comments");
call(commentDto.getKey());
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class DeleteCommentActionTest method fail_when_comment_does_not_belong_to_current_user.
@Test
public void fail_when_comment_does_not_belong_to_current_user() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
userSession.logIn("another").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("You can only delete your own comments");
call(commentDto.getKey());
}
Aggregations