use of org.sonarqube.ws.client.issue.AddCommentRequest 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.client.issue.AddCommentRequest 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.client.issue.AddCommentRequest 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.client.issue.AddCommentRequest 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();
}
use of org.sonarqube.ws.client.issue.AddCommentRequest in project sonarqube by SonarSource.
the class AddCommentAction method toWsRequest.
private static AddCommentRequest toWsRequest(Request request) {
AddCommentRequest wsRequest = new AddCommentRequest(request.mandatoryParam(PARAM_ISSUE), request.mandatoryParam(PARAM_TEXT));
checkArgument(!isNullOrEmpty(wsRequest.getText()), "Cannot add empty comment to an issue");
return wsRequest;
}
Aggregations