Search in sources :

Example 11 with IssueChangeDto

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);
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Response(org.sonar.api.server.ws.Response) TestResponse(org.sonar.server.ws.TestResponse) Request(org.sonar.api.server.ws.Request) TestRequest(org.sonar.server.ws.TestRequest) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 12 with IssueChangeDto

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);
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Response(org.sonar.api.server.ws.Response) TestResponse(org.sonar.server.ws.TestResponse) Request(org.sonar.api.server.ws.Request) TestRequest(org.sonar.server.ws.TestRequest) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 13 with IssueChangeDto

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");
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 14 with IssueChangeDto

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");
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 15 with IssueChangeDto

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(), "");
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Aggregations

IssueChangeDto (org.sonar.db.issue.IssueChangeDto)23 Test (org.junit.Test)18 IssueDto (org.sonar.db.issue.IssueDto)15 Request (org.sonar.api.server.ws.Request)5 Response (org.sonar.api.server.ws.Response)5 TestRequest (org.sonar.server.ws.TestRequest)5 TestResponse (org.sonar.server.ws.TestResponse)5 Date (java.util.Date)4 IssueComment (org.sonar.api.issue.IssueComment)2 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)2 FieldDiffs (org.sonar.core.issue.FieldDiffs)2 ComponentDto (org.sonar.db.component.ComponentDto)2 IssueChangeDao (org.sonar.db.issue.IssueChangeDao)2 UserDto (org.sonar.db.user.UserDto)2 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)2 WsTester (org.sonar.server.ws.WsTester)2 DbSession (org.sonar.db.DbSession)1 Component (org.sonar.server.computation.task.projectanalysis.component.Component)1 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)1