Search in sources :

Example 6 with IssueChangeDto

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

Example 7 with IssueChangeDto

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();
}
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 8 with IssueChangeDto

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

Example 9 with IssueChangeDto

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

Example 10 with IssueChangeDto

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());
}
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