use of com.google.gerrit.entities.HumanComment 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.HumanComment in project gerrit by GerritCodeReview.
the class ChangeUpdate method storeRevisionNotes.
/**
* Returns the tree id for the updated tree
*/
private ObjectId storeRevisionNotes(RevWalk rw, ObjectInserter inserter, ObjectId curr) throws ConfigInvalidException, IOException {
if (submitRequirementResults == null && comments.isEmpty() && pushCert == null) {
return null;
}
RevisionNoteMap<ChangeRevisionNote> rnm = getRevisionNoteMap(rw, curr);
RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm);
for (HumanComment c : comments) {
c.tag = tag;
cache.get(c.getCommitId()).putComment(c);
}
if (submitRequirementResults != null) {
if (submitRequirementResults.isEmpty()) {
ObjectId latestPsCommitId = Iterables.getLast(getNotes().getPatchSets().values()).commitId();
cache.get(latestPsCommitId).createEmptySubmitRequirementResults();
} else {
for (SubmitRequirementResult sr : submitRequirementResults) {
cache.get(sr.patchSetCommitId()).putSubmitRequirementResult(sr);
}
}
}
if (pushCert != null) {
checkState(commit != null);
cache.get(ObjectId.fromString(commit)).setPushCertificate(pushCert);
}
Map<ObjectId, RevisionNoteBuilder> builders = cache.getBuilders();
checkComments(rnm.revisionNotes, builders);
for (Map.Entry<ObjectId, RevisionNoteBuilder> e : builders.entrySet()) {
ObjectId data = inserter.insert(OBJ_BLOB, e.getValue().build(noteUtil.getChangeNoteJson()));
rnm.noteMap.set(e.getKey(), data);
}
return rnm.noteMap.writeTree(inserter);
}
use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.
the class CommentThreadsTest method threadsIgnoreDuplicateChildren.
@Test
public void threadsIgnoreDuplicateChildren() {
HumanComment root = createComment("root");
HumanComment child1 = asReply(createComment("child1"), "root");
ImmutableList<HumanComment> comments = ImmutableList.of(root, child1, child1);
ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreads();
ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(root, child1));
assertThat(commentThreads).isEqualTo(expectedThreads);
}
use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.
the class CommentThreadsTest method threadsCanBeCreatedFromUnorderedComments.
@Test
public void threadsCanBeCreatedFromUnorderedComments() {
HumanComment root = createComment("root");
HumanComment child1 = asReply(createComment("child1"), "root");
HumanComment child2 = asReply(createComment("child2"), "child1");
HumanComment child3 = asReply(createComment("child3"), "child2");
ImmutableList<HumanComment> comments = ImmutableList.of(child2, child1, root, child3);
ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreads();
ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(root, child1, child2, child3));
assertThat(commentThreads).isEqualTo(expectedThreads);
}
use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.
the class CommentThreadsTest method requestedThreadsDoNotNeedToContainReply.
@Test
public void requestedThreadsDoNotNeedToContainReply() {
HumanComment thread1Root = createComment("thread1Root");
HumanComment thread2Root = createComment("thread2Root");
HumanComment thread1Reply = asReply(createComment("thread1Reply"), "thread1Root");
ImmutableList<HumanComment> comments = ImmutableList.of(thread1Root, thread2Root);
ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreadsForChildren(ImmutableList.of(thread1Reply));
ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(thread1Root));
assertThat(commentThreads).isEqualTo(expectedThreads);
}
Aggregations