Search in sources :

Example 41 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class BulkChangeActionTest method remove_assignee.

@Test
public void remove_assignee() throws Exception {
    setUserProjectPermissions(USER);
    IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setAssignee("arthur"));
    BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setAssign("").build());
    checkResponse(response, 1, 1, 0, 0);
    IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
    assertThat(reloaded.getAssignee()).isNull();
    assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 42 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class BulkChangeActionTest method add_tags.

@Test
public void add_tags() throws Exception {
    setUserProjectPermissions(USER, ISSUE_ADMIN);
    IssueDto issueDto = db.issues().insertIssue(newUnresolvedIssue().setTags(asList("tag1", "tag2")));
    BulkChangeWsResponse response = call(BulkChangeRequest.builder().setIssues(singletonList(issueDto.getKey())).setAddTags(singletonList("tag3")).build());
    checkResponse(response, 1, 1, 0, 0);
    IssueDto reloaded = getIssueByKeys(issueDto.getKey()).get(0);
    assertThat(reloaded.getTags()).containsOnly("tag1", "tag2", "tag3");
    assertThat(reloaded.getUpdatedAt()).isEqualTo(NOW);
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) BulkChangeWsResponse(org.sonarqube.ws.Issues.BulkChangeWsResponse) Test(org.junit.Test)

Example 43 with IssueDto

use of org.sonar.db.issue.IssueDto 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 44 with IssueDto

use of org.sonar.db.issue.IssueDto 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 45 with IssueDto

use of org.sonar.db.issue.IssueDto 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)

Aggregations

IssueDto (org.sonar.db.issue.IssueDto)134 Test (org.junit.Test)117 ComponentDto (org.sonar.db.component.ComponentDto)48 RuleDto (org.sonar.db.rule.RuleDto)28 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)19 UserDto (org.sonar.db.user.UserDto)18 WsTester (org.sonar.server.ws.WsTester)18 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)15 FieldDiffs (org.sonar.core.issue.FieldDiffs)14 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)14 ChangelogWsResponse (org.sonarqube.ws.Issues.ChangelogWsResponse)12 TestResponse (org.sonar.server.ws.TestResponse)9 Request (org.sonar.api.server.ws.Request)8 Response (org.sonar.api.server.ws.Response)8 DefaultIssue (org.sonar.core.issue.DefaultIssue)8 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)8 TestRequest (org.sonar.server.ws.TestRequest)8 Date (java.util.Date)6 DbSession (org.sonar.db.DbSession)5 IssueDao (org.sonar.db.issue.IssueDao)4