use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentContextIT method commentContextForGitSubmoduleFiles.
@Test
public void commentContextForGitSubmoduleFiles() throws Exception {
String submodulePath = "submodule_path";
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo).addGitSubmodule(submodulePath, dummyCommit);
PushOneCommit.Result pushResult = push.to("refs/for/master");
String changeId = pushResult.getChangeId();
CommentInput comment = CommentsUtil.newComment(submodulePath, Side.REVISION, 1, "comment", false);
CommentsUtil.addComments(gApi, changeId, pushResult.getCommit().name(), comment);
List<CommentInfo> comments = gApi.changes().id(changeId).commentsRequest().withContext(true).getAsList();
assertThat(comments).hasSize(1);
assertThat(comments.get(0).path).isEqualTo(submodulePath);
assertThat(comments.get(0).contextLines).isEqualTo(createContextLines("1", "Subproject commit " + dummyCommit.getName()));
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentContextIT method createChangeWithCommentLarge.
private String createChangeWithCommentLarge(int startLine, int endLine) throws Exception {
StringBuilder largeContent = new StringBuilder();
for (int i = 0; i < 1000; i++) {
largeContent.append("line " + i + "\n");
}
PushOneCommit.Result result = createChange(testRepo, "master", SUBJECT, FILE_NAME, largeContent.toString(), "topic");
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
Comment.Range commentRange = createCommentRange(startLine, endLine);
CommentInput comment = CommentsUtil.newComment(FILE_NAME, Side.REVISION, commentRange, "comment", false);
CommentsUtil.addComments(gApi, changeId, ps1, comment);
return changeId;
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentContextIT method commentContextForCommitMessageInvalidLine.
@Test
public void commentContextForCommitMessageInvalidLine() throws Exception {
PushOneCommit.Result result = createChange(testRepo, "master", SUBJECT, FILE_NAME, FILE_CONTENT, "topic");
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
CommentInput comment = CommentsUtil.newComment(COMMIT_MSG, Side.REVISION, 100, "comment", false);
CommentsUtil.addComments(gApi, changeId, ps1, comment);
List<CommentInfo> comments = gApi.changes().id(changeId).commentsRequest().withContext(true).getAsList();
assertThat(comments).hasSize(1);
assertThat(comments.get(0).contextLines).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentContextIT method commentContextForRootCommitOnParentSideReturnsEmptyContext.
@Test
public void commentContextForRootCommitOnParentSideReturnsEmptyContext() throws Exception {
// Create a change in a new branch, making the patchset commit a root commit
ChangeInfo changeInfo = createChangeInNewBranch("newBranch");
String changeId = changeInfo.changeId;
String revision = changeInfo.revisions.keySet().iterator().next();
// Write a comment on the parent side of the commit message. Set parent=1 because if unset, our
// handler in PostReview assumes we want to write on the auto-merge commit and fails the
// pre-condition.
CommentInput comment = CommentsUtil.newComment(COMMIT_MSG, Side.PARENT, 0, "comment", false);
comment.parent = 1;
CommentsUtil.addComments(gApi, changeId, revision, comment);
List<CommentInfo> comments = gApi.changes().id(changeId).commentsRequest().withContext(true).getAsList();
assertThat(comments).hasSize(1);
CommentInfo c = comments.stream().collect(MoreCollectors.onlyElement());
assertThat(c.commitId).isEqualTo(ObjectId.zeroId().name());
assertThat(c.contextLines).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput in project gerrit by GerritCodeReview.
the class CommentContextIT method commentContextForMergeList.
@Test
public void commentContextForMergeList() throws Exception {
PushOneCommit.Result result = createMergeCommitChange("refs/for/master");
String changeId = result.getChangeId();
String ps1 = result.getCommit().name();
CommentInput comment = CommentsUtil.newComment(MERGE_LIST, Side.REVISION, 1, "comment", false);
CommentsUtil.addComments(gApi, changeId, ps1, comment);
List<CommentInfo> comments = gApi.changes().id(changeId).commentsRequest().withContext(true).getAsList();
assertThat(comments).hasSize(1);
assertThat(comments.get(0).contextLines).containsExactlyElementsIn(createContextLines("1", "Merge List:"));
}
Aggregations