Search in sources :

Example 21 with HumanComment

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

the class CommentThreadsTest method completeThreadWithBranchesCanBeRequestedByReplyToIntermediateComment.

@Test
public void completeThreadWithBranchesCanBeRequestedByReplyToIntermediateComment() {
    HumanComment root = writtenOn(createComment("root"), Instant.ofEpochMilli(1));
    HumanComment sibling1 = writtenOn(asReply(createComment("sibling1"), "root"), Instant.ofEpochMilli(2));
    HumanComment sibling2 = writtenOn(asReply(createComment("sibling2"), "root"), Instant.ofEpochMilli(3));
    HumanComment sibling1Child = writtenOn(asReply(createComment("sibling1Child"), "sibling1"), Instant.ofEpochMilli(4));
    HumanComment sibling2Child = writtenOn(asReply(createComment("sibling2Child"), "sibling2"), Instant.ofEpochMilli(5));
    HumanComment reply = asReply(createComment("sibling1"), "root");
    ImmutableList<HumanComment> comments = ImmutableList.of(root, sibling1, sibling2, sibling1Child, sibling2Child);
    ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreadsForChildren(ImmutableList.of(reply));
    ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(root, sibling1, sibling2, sibling1Child, sibling2Child));
    assertThat(commentThreads).isEqualTo(expectedThreads);
}
Also used : HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 22 with HumanComment

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

the class CommentThreadsTest method specificThreadsCanBeRequestedByTheirReply.

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

Example 23 with HumanComment

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

the class CommentThreadsTest method threadsCanBeCreatedFromSingleRoot.

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

Example 24 with HumanComment

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

the class CommentThreadsTest method childWithNotAvailableParentIsAssumedToBeRoot.

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

Example 25 with HumanComment

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

the class CommentThreadsTest method branchedThreadsAreFlattenedAccordingToDate.

@Test
public void branchedThreadsAreFlattenedAccordingToDate() {
    HumanComment root = writtenOn(createComment("root"), Instant.ofEpochMilli(1));
    HumanComment sibling1 = writtenOn(asReply(createComment("sibling1"), "root"), Instant.ofEpochMilli(2));
    HumanComment sibling2 = writtenOn(asReply(createComment("sibling2"), "root"), Instant.ofEpochMilli(3));
    HumanComment sibling1Child = writtenOn(asReply(createComment("sibling1Child"), "sibling1"), Instant.ofEpochMilli(4));
    HumanComment sibling2Child = writtenOn(asReply(createComment("sibling2Child"), "sibling2"), Instant.ofEpochMilli(5));
    ImmutableList<HumanComment> comments = ImmutableList.of(sibling2, sibling2Child, sibling1, sibling1Child, root);
    ImmutableSet<CommentThread<HumanComment>> commentThreads = CommentThreads.forComments(comments).getThreads();
    ImmutableSet<CommentThread<HumanComment>> expectedThreads = ImmutableSet.of(toThread(root, sibling1, sibling2, sibling1Child, sibling2Child));
    assertThat(commentThreads).isEqualTo(expectedThreads);
}
Also used : HumanComment(com.google.gerrit.entities.HumanComment) 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