Search in sources :

Example 1 with AssignRequest

use of org.sonarqube.ws.client.issue.AssignRequest in project sonarqube by SonarSource.

the class IssueActionTest method assign.

/**
   * SONAR-4287
   */
@Test
public void assign() {
    assertThat(randomIssue.hasAssignee()).isFalse();
    Issues.SearchWsResponse response = issueRule.search(new SearchWsRequest().setIssues(singletonList(randomIssue.getKey())));
    assertThat(response.getUsers().getUsersList()).isEmpty();
    issuesService.assign(new AssignRequest(randomIssue.getKey(), "admin"));
    assertThat(issueRule.search(new SearchWsRequest().setAssignees(singletonList("admin"))).getIssuesList()).hasSize(1);
    projectAnalysis.run();
    Issue reloaded = issueRule.getByKey(randomIssue.getKey());
    assertThat(reloaded.getAssignee()).isEqualTo("admin");
    assertThat(reloaded.getCreationDate()).isEqualTo(randomIssue.getCreationDate());
    response = issueRule.search(new SearchWsRequest().setIssues(singletonList(randomIssue.getKey())).setAdditionalFields(singletonList("users")));
    assertThat(response.getUsers().getUsersList().stream().filter(user -> "admin".equals(user.getLogin())).findFirst()).isPresent();
    assertThat(response.getUsers().getUsersList().stream().filter(user -> "Administrator".equals(user.getName())).findFirst()).isPresent();
    // unassign
    issuesService.assign(new AssignRequest(randomIssue.getKey(), null));
    reloaded = issueRule.getByKey(randomIssue.getKey());
    assertThat(reloaded.hasAssignee()).isFalse();
    assertThat(issueRule.search(new SearchWsRequest().setAssignees(singletonList("admin"))).getIssuesList()).isEmpty();
}
Also used : EditCommentRequest(org.sonarqube.ws.client.issue.EditCommentRequest) Issues(org.sonarqube.ws.Issues) ItUtils.toDatetime(util.ItUtils.toDatetime) Issue(org.sonarqube.ws.Issues.Issue) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ProjectAnalysis(util.ProjectAnalysis) IssuesService(org.sonarqube.ws.client.issue.IssuesService) Test(org.junit.Test) SetSeverityRequest(org.sonarqube.ws.client.issue.SetSeverityRequest) Collections.singletonList(java.util.Collections.singletonList) ItUtils.newAdminWsClient(util.ItUtils.newAdminWsClient) List(java.util.List) BLOCKER(org.sonarqube.ws.Common.Severity.BLOCKER) Rule(org.junit.Rule) ProjectAnalysisRule(util.ProjectAnalysisRule) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) AddCommentRequest(org.sonarqube.ws.client.issue.AddCommentRequest) IssueRule(util.issue.IssueRule) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) AssignRequest(org.sonarqube.ws.client.issue.AssignRequest) Before(org.junit.Before) Issue(org.sonarqube.ws.Issues.Issue) Issues(org.sonarqube.ws.Issues) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) AssignRequest(org.sonarqube.ws.client.issue.AssignRequest) Test(org.junit.Test)

Example 2 with AssignRequest

use of org.sonarqube.ws.client.issue.AssignRequest in project sonarqube by SonarSource.

the class IssueActionTest method fail_assign_if_assignee_does_not_exist.

/**
   * SONAR-4287
   */
@Test
public void fail_assign_if_assignee_does_not_exist() {
    assertThat(randomIssue.hasAssignee()).isFalse();
    try {
        issuesService.assign(new AssignRequest(randomIssue.getKey(), "unknown"));
        fail();
    } catch (org.sonarqube.ws.client.HttpException ex) {
        assertThat(ex.code()).isEqualTo(400);
    }
}
Also used : AssignRequest(org.sonarqube.ws.client.issue.AssignRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 AssignRequest (org.sonarqube.ws.client.issue.AssignRequest)2 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 ClassRule (org.junit.ClassRule)1 Rule (org.junit.Rule)1 BLOCKER (org.sonarqube.ws.Common.Severity.BLOCKER)1 Issues (org.sonarqube.ws.Issues)1 Issue (org.sonarqube.ws.Issues.Issue)1 AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)1 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)1 IssuesService (org.sonarqube.ws.client.issue.IssuesService)1 SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)1 SetSeverityRequest (org.sonarqube.ws.client.issue.SetSeverityRequest)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.toDatetime (util.ItUtils.toDatetime)1 ProjectAnalysis (util.ProjectAnalysis)1