use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentMultipleOnePatchsetOneFileBothSides.
@Test
public void patchLineCommentMultipleOnePatchsetOneFileBothSides() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
String uuid1 = "uuid1";
String uuid2 = "uuid2";
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
String messageForBase = "comment for base";
String messageForPS = "comment for ps";
CommentRange range = new CommentRange(1, 1, 2, 1);
Instant now = TimeUtil.now();
PatchSet.Id psId = c.currentPatchSetId();
HumanComment commentForBase = newComment(psId, "filename", uuid1, range, range.getEndLine(), otherUser, null, now, messageForBase, (short) 0, commitId1, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, commentForBase);
update.commit();
update = newUpdate(c, otherUser);
HumanComment commentForPS = newComment(psId, "filename", uuid2, range, range.getEndLine(), otherUser, null, now, messageForPS, (short) 1, commitId2, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, commentForPS);
update.commit();
assertThat(newNotes(c).getHumanComments()).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId1, commentForBase, commitId2, commentForPS));
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentsMultipleDraftsBothSidesPublishAll.
@Test
public void patchLineCommentsMultipleDraftsBothSidesPublishAll() throws Exception {
Change c = newChange();
String uuid1 = "uuid1";
String uuid2 = "uuid2";
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
CommentRange range1 = new CommentRange(1, 1, 2, 2);
CommentRange range2 = new CommentRange(2, 2, 3, 3);
String filename = "filename1";
Instant now = TimeUtil.now();
PatchSet.Id psId = c.currentPatchSetId();
// Write two drafts, one on each side of the patchset.
ChangeUpdate update = newUpdate(c, otherUser);
update.setPatchSetId(psId);
HumanComment baseComment = newComment(psId, filename, uuid1, range1, range1.getEndLine(), otherUser, null, now, "comment on base", (short) 0, commitId1, false);
HumanComment psComment = newComment(psId, filename, uuid2, range2, range2.getEndLine(), otherUser, null, now, "comment on ps", (short) 1, commitId2, false);
update.putComment(HumanComment.Status.DRAFT, baseComment);
update.putComment(HumanComment.Status.DRAFT, psComment);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId1, baseComment, commitId2, psComment));
assertThat(notes.getHumanComments()).isEmpty();
// Publish both comments.
update = newUpdate(c, otherUser);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, baseComment);
update.putComment(HumanComment.Status.PUBLISHED, psComment);
update.commit();
notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).isEmpty();
assertThat(notes.getHumanComments()).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId1, baseComment, commitId2, psComment));
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentZeroRange.
@Test
public void patchLineCommentZeroRange() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
PatchSet.Id psId = c.currentPatchSetId();
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
CommentRange range = new CommentRange(0, 0, 0, 0);
HumanComment comment = newComment(psId, "file", "uuid", range, range.getEndLine(), otherUser, null, TimeUtil.now(), "message", (short) 1, commitId, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, comment);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getHumanComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentsZeroColumns.
@Test
public void patchLineCommentsZeroColumns() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
PatchSet.Id psId = c.currentPatchSetId();
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
CommentRange range = new CommentRange(1, 0, 2, 0);
HumanComment comment = newComment(psId, "file1", "uuid", range, range.getEndLine(), otherUser, null, TimeUtil.now(), "message", (short) 1, commitId, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, comment);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getHumanComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment));
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentMultiplePatchsets.
@Test
public void patchLineCommentMultiplePatchsets() throws Exception {
Change c = newChange();
String uuid = "uuid";
ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId commitId2 = ObjectId.fromString("abcd4567abcd4567abcd4567abcd4567abcd4567");
CommentRange range = new CommentRange(1, 1, 2, 1);
PatchSet.Id ps1 = c.currentPatchSetId();
String filename = "filename1";
short side = (short) 1;
ChangeUpdate update = newUpdate(c, otherUser);
Instant now = TimeUtil.now();
HumanComment comment1 = newComment(ps1, filename, uuid, range, range.getEndLine(), otherUser, null, now, "comment on ps1", side, commitId1, false);
update.setPatchSetId(ps1);
update.putComment(HumanComment.Status.PUBLISHED, comment1);
update.commit();
incrementPatchSet(c);
PatchSet.Id ps2 = c.currentPatchSetId();
update = newUpdate(c, otherUser);
now = TimeUtil.now();
HumanComment comment2 = newComment(ps2, filename, uuid, range, range.getEndLine(), otherUser, null, now, "comment on ps2", side, commitId2, false);
update.setPatchSetId(ps2);
update.putComment(HumanComment.Status.PUBLISHED, comment2);
update.commit();
assertThat(newNotes(c).getHumanComments()).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId1, comment1, commitId2, comment2));
}
Aggregations