use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentEmptyFilename.
@Test
public void patchLineCommentEmptyFilename() 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, 2, 3, 4);
HumanComment comment = newComment(psId, "", "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 ChangeUpdateTest method bypassMaxUpdatesShouldBeFalseWhenCommentsAndChangesToAttentionSetCoexist.
@Test
public void bypassMaxUpdatesShouldBeFalseWhenCommentsAndChangesToAttentionSetCoexist() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
addToAttentionSet(update);
// Add a comment
RevCommit commit = tr.commit().message("PS2").create();
update.putComment(HumanComment.Status.PUBLISHED, newComment(c.currentPatchSetId(), "a.txt", "uuid1", new CommentRange(1, 2, 3, 4), 1, changeOwner, null, TimeUtil.now(), "Comment", (short) 1, commit, false));
update.commit();
assertThat(update.bypassMaxUpdates()).isFalse();
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method tagInlineComments.
@Test
public void tagInlineComments() throws Exception {
String tag = "jenkins";
Change c = newChange();
RevCommit commit = tr.commit().message("PS2").create();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putComment(HumanComment.Status.PUBLISHED, newComment(c.currentPatchSetId(), "a.txt", "uuid1", new CommentRange(1, 2, 3, 4), 1, changeOwner, null, TimeUtil.now(), "Comment", (short) 1, commit, false));
update.setTag(tag);
update.commit();
ChangeNotes notes = newNotes(c);
ImmutableListMultimap<ObjectId, HumanComment> comments = notes.getHumanComments();
assertThat(comments).hasSize(1);
assertThat(comments.entries().asList().get(0).getValue().tag).isEqualTo(tag);
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentSingleDraftToPublished.
@Test
public void patchLineCommentSingleDraftToPublished() throws Exception {
Change c = newChange();
String uuid = "uuid";
ObjectId commitId = 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, commitId, false);
update.setPatchSetId(ps1);
update.putComment(HumanComment.Status.DRAFT, comment1);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1));
assertThat(notes.getHumanComments()).isEmpty();
update = newUpdate(c, otherUser);
update.setPatchSetId(ps1);
update.putComment(HumanComment.Status.PUBLISHED, comment1);
update.commit();
notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).isEmpty();
assertThat(notes.getHumanComments()).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1));
}
use of com.google.gerrit.entities.CommentRange in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentMultipleOnePatchsetOneFile.
@Test
public void patchLineCommentMultipleOnePatchsetOneFile() throws Exception {
Change c = newChange();
String uuid1 = "uuid1";
String uuid2 = "uuid2";
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
CommentRange range = new CommentRange(1, 1, 2, 1);
PatchSet.Id psId = c.currentPatchSetId();
String filename = "filename";
short side = (short) 1;
ChangeUpdate update = newUpdate(c, otherUser);
Instant timeForComment1 = TimeUtil.now();
Instant timeForComment2 = TimeUtil.now();
HumanComment comment1 = newComment(psId, filename, uuid1, range, range.getEndLine(), otherUser, null, timeForComment1, "comment 1", side, commitId, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, comment1);
update.commit();
update = newUpdate(c, otherUser);
HumanComment comment2 = newComment(psId, filename, uuid2, range, range.getEndLine(), otherUser, null, timeForComment2, "comment 2", side, commitId, false);
update.setPatchSetId(psId);
update.putComment(HumanComment.Status.PUBLISHED, comment2);
update.commit();
assertThat(newNotes(c).getHumanComments()).containsExactlyEntriesIn(ImmutableListMultimap.of(commitId, comment1, commitId, comment2)).inOrder();
}
Aggregations