use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedRangeCommentStartingWithinLastModifiedLineBecomesFileComment.
@Test
public void portedRangeCommentStartingWithinLastModifiedLineBecomesFileComment() 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 one\nLine two\nLine 3\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();
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedLineCommentCanHandleDeletedLines.
@Test
public void portedLineCommentCanHandleDeletedLines() 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).onLine(3).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedRangeCommentBecomesFileCommentOnConflict.
@Test
public void portedRangeCommentBecomesFileCommentOnConflict() 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 two\nLine three\nLine 4\n").create();
// Add comment.
String commentUuid = newComment(patchset1Id).fromLine(2).charOffset(2).toLine(3).charOffset(5).ofFile("myFile").create();
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
assertThatMap(portedComments).keys().containsExactly("myFile");
CommentInfo portedComment = extractSpecificComment(portedComments, commentUuid);
assertThat(portedComment).range().isNull();
assertThat(portedComment).line().isNull();
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedRangeCommentAdditionallyAppearsOnCopyAtIndependentPosition.
@Test
public void portedRangeCommentAdditionallyAppearsOnCopyAtIndependentPosition() 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();
// Gerrit currently only identifies a copy if a rename also happens at the same time. Modify the
// renamed file slightly different than the copied file so that the end location of the comment
// is different. Modify the renamed file less so that Gerrit/Git picks it as the renamed one.
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().file("myFile").delete().file("renamedFiled").content("Line 1\nLine 1.1\nLine 2\nLine 3\nLine 4\n").file("copiedFile").content("Line 1\nLine 1.1\nLine 1.2\nLine 2\nLine 3\nLine 4\n").create();
// Add comment.
String commentUuid = newComment(patchset1Id).fromLine(3).charOffset(2).toLine(4).charOffset(5).ofFile("myFile").create();
Map<String, List<CommentInfo>> portedComments = getPortedComments(patchset2Id);
assertThatMap(portedComments).keys().containsExactly("renamedFiled", "copiedFile");
CommentInfo portedCommentOnRename = getOnlyElement(portedComments.get("renamedFiled"));
assertThat(portedCommentOnRename).uuid().isEqualTo(commentUuid);
assertThat(portedCommentOnRename).range().startLine().isEqualTo(4);
assertThat(portedCommentOnRename).range().startCharacter().isEqualTo(2);
assertThat(portedCommentOnRename).range().endLine().isEqualTo(5);
assertThat(portedCommentOnRename).range().endCharacter().isEqualTo(5);
CommentInfo portedCommentOnCopy = getOnlyElement(portedComments.get("copiedFile"));
assertThat(portedCommentOnCopy).uuid().isEqualTo(commentUuid);
assertThat(portedCommentOnCopy).range().startLine().isEqualTo(5);
assertThat(portedCommentOnCopy).range().startCharacter().isEqualTo(2);
assertThat(portedCommentOnCopy).range().endLine().isEqualTo(6);
assertThat(portedCommentOnCopy).range().endCharacter().isEqualTo(5);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedLineCommentOnLineJustBeforeModificationCanBePorted.
@Test
public void portedLineCommentOnLineJustBeforeModificationCanBePorted() 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(2).ofFile("myFile").create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
}
Aggregations