use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentsIT method commentsOnDeletedFileIsIncludedInEmails.
@Test
public void commentsOnDeletedFileIsIncludedInEmails() throws Exception {
// Create a change with a file.
createChange("subject", "f1.txt", "content");
// Stack a second change that deletes the file.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
gApi.changes().id(changeId).edit().deleteFile("f1.txt");
gApi.changes().id(changeId).edit().publish();
String currentRevision = gApi.changes().id(changeId).get().currentRevision;
// Add a comment on the deleted file on the parent side.
email.clear();
CommentInput commentInput = CommentsUtil.newComment("f1.txt", Side.PARENT, /* line= */
1, /* message= */
"Comment text", /* unresolved= */
false);
CommentsUtil.addComments(gApi, changeId, currentRevision, commentInput);
// Assert email contains the comment text.
assertThat(email.getMessages()).hasSize(1);
Message commentMessage = email.getMessages().get(0);
assertThat(commentMessage.body()).contains("Patch Set 2:\n\n(1 comment)\n\nFile f1.txt:");
assertThat(commentMessage.body()).contains("PS2, Line 1: content\nComment text");
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentsIT method patchsetLevelCommentCantHaveSide.
@Test
public void patchsetLevelCommentCantHaveSide() throws Exception {
PushOneCommit.Result result = createChange();
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
CommentInput input = CommentsUtil.newCommentWithOnlyMandatoryFields(PATCHSET_LEVEL, "comment");
input.side = Side.REVISION;
BadRequestException ex = assertThrows(BadRequestException.class, () -> CommentsUtil.addComments(gApi, changeId, ps1, input));
assertThat(ex.getMessage()).contains("side");
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentsIT method patchsetLevelCommentEmailNotification.
@Test
public void patchsetLevelCommentEmailNotification() throws Exception {
PushOneCommit.Result result = createChange();
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
CommentInput comment = CommentsUtil.newCommentWithOnlyMandatoryFields(PATCHSET_LEVEL, "The change looks good, LGTM");
CommentsUtil.addComments(gApi, changeId, ps1, comment);
String emailBody = Iterables.getOnlyElement(email.getMessages()).body();
assertThat(emailBody).contains("Patchset");
assertThat(emailBody).doesNotContain("/PATCHSET_LEVEL");
assertThat(emailBody).contains("The change looks good, LGTM");
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentsIT method cannotCreateCommentWithInvalidInReplyTo.
@Test
public void cannotCreateCommentWithInvalidInReplyTo() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
CommentInput comment = CommentsUtil.newComment(COMMIT_MSG, "comment 1 reply");
comment.inReplyTo = "invalid";
BadRequestException exception = assertThrows(BadRequestException.class, () -> CommentsUtil.addComments(gApi, changeId, comment));
assertThat(exception.getMessage()).contains(String.format("%s not found", comment.inReplyTo));
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentsIT method canCreateHumanCommentWithHumanCommentAsParent.
@Test
public void canCreateHumanCommentWithHumanCommentAsParent() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
String parentCommentUuid = changeOperations.change(changeId).currentPatchset().newComment().create();
CommentInput createdCommentInput = CommentsUtil.newComment(COMMIT_MSG, "comment reply");
createdCommentInput.inReplyTo = parentCommentUuid;
CommentsUtil.addComments(gApi, changeId, createdCommentInput);
CommentInfo resultNewComment = Iterables.getOnlyElement(getPublishedCommentsAsList(changeId).stream().filter(c -> c.message.equals("comment reply")).collect(toImmutableSet()));
assertThat(resultNewComment.inReplyTo).isEqualTo(parentCommentUuid);
}
Aggregations