Add dummy REST API endpoint for preview Fix
This commit adds dummy endpoint for preview Fix. Endpoint always returns empty map Change-Id: I64d7e2f46085275ff3f5e2aea397d5ce18da2741
This commit is contained in:

committed by
Edwin Kempin

parent
8d72356e2b
commit
d0752cf0a3
@@ -22,6 +22,7 @@ import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.CherryPickChangeInfo;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.common.DiffInfo;
|
||||
import com.google.gerrit.extensions.common.EditInfo;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.extensions.common.MergeableInfo;
|
||||
@@ -125,6 +126,8 @@ public interface RevisionApi {
|
||||
*/
|
||||
EditInfo applyFix(String fixId) throws RestApiException;
|
||||
|
||||
Map<String, DiffInfo> getFixPreview(String fixId) throws RestApiException;
|
||||
|
||||
DraftApi createDraft(DraftInput in) throws RestApiException;
|
||||
|
||||
DraftApi draft(String id) throws RestApiException;
|
||||
@@ -295,6 +298,11 @@ public interface RevisionApi {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DiffInfo> getFixPreview(String fixId) throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<CommentInfo>> drafts() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
|
@@ -44,6 +44,7 @@ import com.google.gerrit.extensions.common.CherryPickChangeInfo;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.common.DescriptionInput;
|
||||
import com.google.gerrit.extensions.common.DiffInfo;
|
||||
import com.google.gerrit.extensions.common.EditInfo;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
@@ -71,6 +72,7 @@ import com.google.gerrit.server.restapi.change.Files;
|
||||
import com.google.gerrit.server.restapi.change.Fixes;
|
||||
import com.google.gerrit.server.restapi.change.GetCommit;
|
||||
import com.google.gerrit.server.restapi.change.GetDescription;
|
||||
import com.google.gerrit.server.restapi.change.GetFixPreview;
|
||||
import com.google.gerrit.server.restapi.change.GetMergeList;
|
||||
import com.google.gerrit.server.restapi.change.GetPatch;
|
||||
import com.google.gerrit.server.restapi.change.GetRelated;
|
||||
@@ -126,6 +128,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
private final ListRevisionComments listComments;
|
||||
private final ListRobotComments listRobotComments;
|
||||
private final ApplyFix applyFix;
|
||||
private final GetFixPreview getFixPreview;
|
||||
private final Fixes fixes;
|
||||
private final ListRevisionDrafts listDrafts;
|
||||
private final CreateDraftComment createDraft;
|
||||
@@ -169,6 +172,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
ListRevisionComments listComments,
|
||||
ListRobotComments listRobotComments,
|
||||
ApplyFix applyFix,
|
||||
GetFixPreview getFixPreview,
|
||||
Fixes fixes,
|
||||
ListRevisionDrafts listDrafts,
|
||||
CreateDraftComment createDraft,
|
||||
@@ -211,6 +215,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
this.robotComments = robotComments;
|
||||
this.listRobotComments = listRobotComments;
|
||||
this.applyFix = applyFix;
|
||||
this.getFixPreview = getFixPreview;
|
||||
this.fixes = fixes;
|
||||
this.listDrafts = listDrafts;
|
||||
this.createDraft = createDraft;
|
||||
@@ -451,6 +456,15 @@ class RevisionApiImpl implements RevisionApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DiffInfo> getFixPreview(String fixId) throws RestApiException {
|
||||
try {
|
||||
return getFixPreview.apply(fixes.parse(revision, IdString.fromDecoded(fixId))).value();
|
||||
} catch (Exception e) {
|
||||
throw asRestApiException("Cannot get fix preview", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentInfo> draftsAsList() throws RestApiException {
|
||||
try {
|
||||
|
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2019 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.gerrit.extensions.common.DiffInfo;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.change.FixResource;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class GetFixPreview implements RestReadView<FixResource> {
|
||||
|
||||
@Override
|
||||
public Response<Map<String, DiffInfo>> apply(FixResource resource) {
|
||||
Map<String, DiffInfo> result = new HashMap<>();
|
||||
return Response.ok(result);
|
||||
}
|
||||
}
|
@@ -160,6 +160,7 @@ public class Module extends RestApiModule {
|
||||
get(ROBOT_COMMENT_KIND).to(GetRobotComment.class);
|
||||
child(REVISION_KIND, "fixes").to(Fixes.class);
|
||||
post(FIX_KIND, "apply").to(ApplyFix.class);
|
||||
get(FIX_KIND, "preview").to(GetFixPreview.class);
|
||||
|
||||
child(REVISION_KIND, "files").to(Files.class);
|
||||
put(FILE_KIND, "reviewed").to(PutReviewed.class);
|
||||
|
Reference in New Issue
Block a user