use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedLineCommentOnLastLineOfModificationBecomesFileComment.
@Test
public void portedLineCommentOnLastLineOfModificationBecomesFileComment() 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\nSome completely\ndifferent\ncontent\n").create();
// Add comment.
String commentUuid = newComment(patchset1Id).onLine(4).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).line().isNull();
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentOnFirstParentIsPortedToNewPosition.
@Test
public void commentOnFirstParentIsPortedToNewPosition() throws Exception {
// Set up change and patchsets.
Change.Id parent1ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id parent2ChangeId = changeOps.newChange().file("file2").content("Line 1\n").create();
Change.Id childChangeId = changeOps.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).file("file1").content("Line one\n").create();
PatchSet.Id childPatchset1Id = changeOps.change(childChangeId).currentPatchset().get().patchsetId();
PatchSet.Id parent1Patchset2Id = changeOps.change(parent1ChangeId).newPatchset().file("file1").content("Line 0\nLine 1\n").create();
PatchSet.Id childPatchset2Id = changeOps.change(childChangeId).newPatchset().parents().patchset(parent1Patchset2Id).and().change(parent2ChangeId).create();
// Add comment.
String commentUuid = newComment(childPatchset1Id).onParentCommit().onLine(1).ofFile("file1").create();
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedLineCommentCanHandlePureRename.
@Test
public void portedLineCommentCanHandlePureRename() 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").renameTo("newFileName").create();
// Add comment.
String commentUuid = newComment(patchset1Id).onLine(3).ofFile("myFile").create();
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
assertThatMap(portedComments).keys().containsExactly("newFileName");
CommentInfo portedComment = extractSpecificComment(portedComments, commentUuid);
assertThat(portedComment).line().isEqualTo(3);
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedPublishedCommentHasOriginalAuthor.
@Test
public void portedPublishedCommentHasOriginalAuthor() throws Exception {
// Set up change and patchsets.
Account.Id authorId = accountOps.newAccount().create();
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).author(authorId).create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).author().id().isEqualTo(authorId.get());
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedRangeCommentStartingBeforeButEndingAfterModifiedLineBecomesFileComment.
// We could actually do better in such a situation but that involves some careful improvements
// which would need to be covered with even more tests (e.g. several modifications could be within
// the comment range; several comments could surround it; other modifications could have occurred
// in the file so that start is shifted too but different than end). That's why we go for the
// simple solution now (-> just map to file comment).
@Test
public void portedRangeCommentStartingBeforeButEndingAfterModifiedLineBecomesFileComment() 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).fromLine(2).charOffset(2).toLine(4).charOffset(5).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).range().isNull();
assertThat(portedComment).line().isNull();
}
Aggregations