use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest method edit_comment_using_deprecated_key_parameter.
@Test
public void edit_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));
IssueChangeDto issueComment = dbClient.issueChangeDao().selectCommentByKey(dbTester.getSession(), commentDto.getKey()).get();
assertThat(issueComment.getChangeData()).isEqualTo("please have a look");
assertThat(issueComment.getUpdatedAt()).isEqualTo(NOW);
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest method edit_comment.
@Test
public void edit_comment() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
call(commentDto.getKey(), "please have a look");
verify(responseWriter).write(eq(issueDto.getKey()), any(Request.class), any(Response.class));
IssueChangeDto issueComment = dbClient.issueChangeDao().selectCommentByKey(dbTester.getSession(), commentDto.getKey()).get();
assertThat(issueComment.getChangeData()).isEqualTo("please have a look");
assertThat(issueComment.getUpdatedAt()).isEqualTo(NOW);
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest 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 edit your own comments");
call(commentDto.getKey(), "please have a look");
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest 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(), "please have a look");
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest method fail_when_empty_comment_text.
@Test
public void fail_when_empty_comment_text() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, "john", "please fix it");
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
expectedException.expect(IllegalArgumentException.class);
call(commentDto.getKey(), "");
}
Aggregations