Search in sources :

Example 66 with HumanComment

use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.

the class CommentThreadsTest method requestedThreadsAreEmptyIfReplyDoesNotReferToAThread.

@Test
public void requestedThreadsAreEmptyIfReplyDoesNotReferToAThread() {
    HumanComment root = createComment("root");
    HumanComment reply = asReply(createComment("reply"), "invalid");
    ImmutableList<HumanComment> comments = ImmutableList.of(root);
    ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreadsForChildren(ImmutableList.of(reply));
    ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of();
    assertThat(commentThreads).isEqualTo(expectedThreads);
}
Also used : HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 67 with HumanComment

use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.

the class CommentThreadsTest method threadsIgnoreDuplicateRoots.

@Test
public void threadsIgnoreDuplicateRoots() {
    HumanComment root = createComment("root");
    HumanComment child1 = asReply(createComment("child1"), "root");
    ImmutableList<HumanComment> comments = ImmutableList.of(root, root, child1);
    ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreads();
    ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(root, child1));
    assertThat(commentThreads).isEqualTo(expectedThreads);
}
Also used : HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 68 with HumanComment

use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.

the class CommentThreadsTest method commentsAreOrderedIntoCorrectThreads.

@Test
public void commentsAreOrderedIntoCorrectThreads() {
    HumanComment thread1Root = createComment("thread1Root");
    HumanComment thread1Child1 = asReply(createComment("thread1Child1"), "thread1Root");
    HumanComment thread1Child2 = asReply(createComment("thread1Child2"), "thread1Child1");
    HumanComment thread2Root = createComment("thread2Root");
    HumanComment thread2Child1 = asReply(createComment("thread2Child1"), "thread2Root");
    ImmutableList<HumanComment> comments = ImmutableList.of(thread2Root, thread1Child2, thread1Child1, thread1Root, thread2Child1);
    ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreads();
    ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(thread1Root, thread1Child1, thread1Child2), toThread(thread2Root, thread2Child1));
    assertThat(commentThreads).isEqualTo(expectedThreads);
}
Also used : HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 69 with HumanComment

use of com.google.gerrit.entities.HumanComment in project gerrit by GerritCodeReview.

the class ChangeNotesTest method patchLineCommentsFileComment.

@Test
public void patchLineCommentsFileComment() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, otherUser);
    PatchSet.Id psId = c.currentPatchSetId();
    ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    HumanComment comment = newComment(psId, "file1", "uuid", null, 0, 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));
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) PatchSet(com.google.gerrit.entities.PatchSet) Change(com.google.gerrit.entities.Change) HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 70 with HumanComment

use of com.google.gerrit.entities.HumanComment 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);
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) CommentRange(com.google.gerrit.entities.CommentRange) Change(com.google.gerrit.entities.Change) HumanComment(com.google.gerrit.entities.HumanComment) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

HumanComment (com.google.gerrit.entities.HumanComment)87 Test (org.junit.Test)53 Change (com.google.gerrit.entities.Change)39 PatchSet (com.google.gerrit.entities.PatchSet)39 ObjectId (org.eclipse.jgit.lib.ObjectId)39 CommentRange (com.google.gerrit.entities.CommentRange)25 Instant (java.time.Instant)20 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)14 Comment (com.google.gerrit.entities.Comment)11 Project (com.google.gerrit.entities.Project)11 Map (java.util.Map)11 ArrayList (java.util.ArrayList)8 RevCommit (org.eclipse.jgit.revwalk.RevCommit)8 HashMap (java.util.HashMap)7 NoteMap (org.eclipse.jgit.notes.NoteMap)7 ImmutableMap (com.google.common.collect.ImmutableMap)6 TraceTimer (com.google.gerrit.server.logging.TraceContext.TraceTimer)6 FluentLogger (com.google.common.flogger.FluentLogger)5 Account (com.google.gerrit.entities.Account)5 BranchNameKey (com.google.gerrit.entities.BranchNameKey)5