diff --git a/java/com/google/gerrit/entities/Comment.java b/java/com/google/gerrit/entities/Comment.java index 2c10c87408..e7ac4e44ef 100644 --- a/java/com/google/gerrit/entities/Comment.java +++ b/java/com/google/gerrit/entities/Comment.java @@ -244,6 +244,7 @@ public abstract class Comment { c.unresolved); this.lineNbr = c.lineNbr; this.realAuthor = c.realAuthor; + this.parentUuid = c.parentUuid; this.range = c.range != null ? new Range(c.range) : null; this.tag = c.tag; this.revId = c.revId; diff --git a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java index 7faae6bceb..45e14178c4 100644 --- a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java +++ b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java @@ -31,11 +31,16 @@ import com.google.common.collect.Lists; import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.PushOneCommit; +import com.google.gerrit.acceptance.testsuite.account.AccountOperations; +import com.google.gerrit.acceptance.testsuite.change.ChangeOperations; +import com.google.gerrit.acceptance.testsuite.change.TestHumanComment; import com.google.gerrit.acceptance.testsuite.project.ProjectOperations; import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations; +import com.google.gerrit.entities.Account; import com.google.gerrit.entities.Change; import com.google.gerrit.entities.HumanComment; import com.google.gerrit.entities.Patch; +import com.google.gerrit.entities.PatchSet; import com.google.gerrit.entities.RefNames; import com.google.gerrit.extensions.api.changes.DeleteCommentInput; import com.google.gerrit.extensions.api.changes.DraftInput; @@ -90,6 +95,8 @@ public class CommentsIT extends AbstractDaemonTest { @Inject private ProjectOperations projectOperations; @Inject private Provider changes; @Inject private Provider postReview; + @Inject private ChangeOperations changeOperations; + @Inject private AccountOperations accountOperations; @Inject private RequestScopeOperations requestScopeOperations; @Inject private CommentsUtil commentsUtil; @Inject private TestCommentHelper testCommentHelper; @@ -726,6 +733,37 @@ public class CommentsIT extends AbstractDaemonTest { assertThat(comment.tag).isEqualTo(tag); } + @Test + public void updatedDraftStillPointsToParentComment() throws Exception { + Account.Id accountId = accountOperations.newAccount().create(); + Change.Id changeId = changeOperations.newChange().create(); + PatchSet.Id patchsetId = changeOperations.change(changeId).currentPatchset().get().patchsetId(); + String parentCommentUuid = + changeOperations.change(changeId).patchset(patchsetId).newComment().create(); + String draftCommentUuid = + changeOperations + .change(changeId) + .patchset(patchsetId) + .newDraftComment() + .parentUuid(parentCommentUuid) + .author(accountId) + .create(); + + // Each user can only see their own drafts. + requestScopeOperations.setApiUser(accountId); + DraftInput draftInput = newDraft(FILE_NAME, Side.REVISION, 0, "bar"); + draftInput.message = "Another comment text."; + gApi.changes() + .id(changeId.get()) + .revision(patchsetId.get()) + .draft(draftCommentUuid) + .update(draftInput); + + TestHumanComment comment = + changeOperations.change(changeId).draftComment(draftCommentUuid).get(); + assertThat(comment.parentUuid()).hasValue(parentCommentUuid); + } + @Test public void listDrafts() throws Exception { String file = "file";