Provide ported draft comments via a separate REST endpoint

All other REST endpoints for comments have a clear separation between
published comments and draft comments. We follow the same approach for
ported comments and hence introduce a dedicated REST endpoint for
ported draft comments.

The existing tests for ported comments also cover most code paths for
ported draft comments as a large amount of the code is shared. We only
add additional tests for varying aspects or those which are outside of
the shared code.

Change-Id: If8802a4f94540284cc1303b278f7f38d120593eb
This commit is contained in:
Alice Kober-Sotzek
2020-08-19 10:22:32 +02:00
parent 717ad95fef
commit bd543094f8
5 changed files with 199 additions and 1 deletions

View File

@@ -80,6 +80,7 @@ import com.google.gerrit.server.restapi.change.GetPatch;
import com.google.gerrit.server.restapi.change.GetRelated;
import com.google.gerrit.server.restapi.change.GetRevisionActions;
import com.google.gerrit.server.restapi.change.ListPortedComments;
import com.google.gerrit.server.restapi.change.ListPortedDrafts;
import com.google.gerrit.server.restapi.change.ListRevisionComments;
import com.google.gerrit.server.restapi.change.ListRevisionDrafts;
import com.google.gerrit.server.restapi.change.ListRobotComments;
@@ -132,6 +133,7 @@ class RevisionApiImpl implements RevisionApi {
private final ListRevisionComments listComments;
private final ListRobotComments listRobotComments;
private final ListPortedComments listPortedComments;
private final ListPortedDrafts listPortedDrafts;
private final ApplyFix applyFix;
private final GetFixPreview getFixPreview;
private final Fixes fixes;
@@ -178,6 +180,7 @@ class RevisionApiImpl implements RevisionApi {
ListRevisionComments listComments,
ListRobotComments listRobotComments,
ListPortedComments listPortedComments,
ListPortedDrafts listPortedDrafts,
ApplyFix applyFix,
GetFixPreview getFixPreview,
Fixes fixes,
@@ -223,6 +226,7 @@ class RevisionApiImpl implements RevisionApi {
this.robotComments = robotComments;
this.listRobotComments = listRobotComments;
this.listPortedComments = listPortedComments;
this.listPortedDrafts = listPortedDrafts;
this.applyFix = applyFix;
this.getFixPreview = getFixPreview;
this.fixes = fixes;
@@ -466,6 +470,15 @@ class RevisionApiImpl implements RevisionApi {
}
}
@Override
public Map<String, List<CommentInfo>> portedDrafts() throws RestApiException {
try {
return listPortedDrafts.apply(revision).value();
} catch (Exception e) {
throw asRestApiException("Cannot retrieve ported draft comments", e);
}
}
@Override
public EditInfo applyFix(String fixId) throws RestApiException {
try {