use of org.sonarqube.ws.Issues.Issue 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.Issues.Issue in project sonarqube by SonarSource.
the class IssueActionTest method should_reject_blank_comment.
/**
* SONAR-4450
*/
@Test
public void should_reject_blank_comment() throws Exception {
try {
issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), " "));
fail();
} catch (org.sonarqube.ws.client.HttpException ex) {
assertThat(ex.code()).isEqualTo(400);
}
Issue reloaded = issueRule.getByKey(randomIssue.getKey());
assertThat(reloaded.getComments().getCommentsList()).isEmpty();
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueActionTest method add_comment.
@Test
public void add_comment() throws Exception {
Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0);
assertThat(comment.getKey()).isNotNull();
assertThat(comment.getHtmlText()).isEqualTo("this is my <strong>comment</strong>");
assertThat(comment.getLogin()).isEqualTo("admin");
assertThat(comment.getCreatedAt()).isNotNull();
// reload issue
Issue reloaded = issueRule.getByKey(randomIssue.getKey());
assertThat(reloaded.getComments().getCommentsList()).hasSize(1);
assertThat(reloaded.getComments().getComments(0).getKey()).isEqualTo(comment.getKey());
assertThat(reloaded.getComments().getComments(0).getHtmlText()).isEqualTo("this is my <strong>comment</strong>");
assertThat(toDatetime(reloaded.getUpdateDate())).isAfter(toDatetime(randomIssue.getUpdateDate()));
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueActionTest method edit_comment.
@Test
public void edit_comment() throws Exception {
Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0);
Issues.Comment editedComment = issuesService.editComment(new EditCommentRequest(comment.getKey(), "new *comment*")).getIssue().getComments().getComments(0);
assertThat(editedComment.getHtmlText()).isEqualTo("new <strong>comment</strong>");
// reload issue
Issue reloaded = issueRule.getByKey(randomIssue.getKey());
assertThat(reloaded.getComments().getCommentsList()).hasSize(1);
assertThat(reloaded.getComments().getComments(0).getHtmlText()).isEqualTo("new <strong>comment</strong>");
}
use of org.sonarqube.ws.Issues.Issue in project sonarqube by SonarSource.
the class IssueActionTest method delete_comment.
@Test
public void delete_comment() throws Exception {
Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0);
Issue issue = issuesService.deleteComment(comment.getKey()).getIssue();
assertThat(issue.getComments().getCommentsList()).isEmpty();
// reload issue
Issue reloaded = issueRule.getByKey(randomIssue.getKey());
assertThat(reloaded.getComments().getCommentsList()).isEmpty();
}
Aggregations