use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedCommentHasUpdatedTimestamp.
@Test
public void portedCommentHasUpdatedTimestamp() throws Exception {
// Set up change and patchsets.
Change.Id changeId = changeOps.newChange().create();
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
// Add comment.
String commentUuid = newComment(patchset1Id).create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).updated().isNotNull();
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedCommentHasOriginalTag.
@Test
public void portedCommentHasOriginalTag() throws Exception {
// Set up change and patchsets.
Change.Id changeId = changeOps.newChange().create();
TestPatchset patchset1 = changeOps.change(changeId).currentPatchset().get();
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
// Add comment.
String commentUuid = newComment(patchset1.patchsetId()).tag("My comment tag").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).tag().isEqualTo("My comment tag");
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentsArePortedWhenAllEditsAreDueToRebase.
@Test
public void commentsArePortedWhenAllEditsAreDueToRebase() throws Exception {
String fileName = "f.txt";
String baseContent = IntStream.rangeClosed(1, 50).mapToObj(number -> String.format("Line %d\n", number)).collect(joining());
ObjectId headCommit = testRepo.getRepository().resolve("HEAD");
ObjectId baseCommit = addCommit(headCommit, fileName, baseContent);
// Create a change on top of baseCommit, modify line 1, then add comment on line 10.
PushOneCommit.Result r = createEmptyChange();
Change.Id changeId = r.getChange().getId();
addModifiedPatchSet(changeId.toString(), fileName, baseContent.replace("Line 1\n", "Line one\n"));
PatchSet.Id ps2Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
newComment(ps2Id).message("Line comment").onLine(10).ofFile(fileName).create();
// Add a commit on top of baseCommit. Delete line 4. Rebase the change on top of this commit.
ObjectId newBase = addCommit(baseCommit, fileName, baseContent.replace("Line 4\n", ""));
rebaseChangeOn(changeId.toString(), newBase);
PatchSet.Id ps3Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
List<CommentInfo> portedComments = flatten(getPortedComments(ps3Id));
assertThat(portedComments).hasSize(1);
int portedLine = portedComments.get(0).line;
BinaryResult fileContent = gApi.changes().id(changeId.get()).current().file(fileName).content();
List<String> lines = Splitter.on("\n").splitToList(fileContent.asString());
// Comment has shifted to L9 instead of L10 because of the deletion of line 4.
assertThat(portedLine).isEqualTo(9);
assertThat(lines.get(portedLine - 1)).isEqualTo("Line 10");
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedRangeCommentCanHandleDeletedLines.
@Test
public void portedRangeCommentCanHandleDeletedLines() throws Exception {
// Set up change and patchsets.
Change.Id changeId = changeOps.newChange().file("myFile").content("Line 1\nLine 2\nLine 3\nLine 4\n").create();
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().file("myFile").content("Line 2\nLine 3\nLine 4\n").create();
// Add comment.
String commentUuid = newComment(patchset1Id).fromLine(3).charOffset(2).toLine(4).charOffset(5).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).range().startLine().isEqualTo(2);
assertThat(portedComment).range().startCharacter().isEqualTo(2);
assertThat(portedComment).range().endLine().isEqualTo(3);
assertThat(portedComment).range().endCharacter().isEqualTo(5);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedLineCommentOnLineJustAfterModificationCanBePorted.
@Test
public void portedLineCommentOnLineJustAfterModificationCanBePorted() throws Exception {
// Set up change and patchsets.
Change.Id changeId = changeOps.newChange().file("myFile").content("Line 1\nLine 2\nLine 3\nLine 4\n").create();
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().file("myFile").content("Line 1\nLine 2\nLine three\nLine 4\n").create();
// Add comment.
String commentUuid = newComment(patchset1Id).onLine(4).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(4);
}
Aggregations