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