LCOV - code coverage report
Current view: top level - extensions/api/changes - RevisionApi.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 12 61 19.7 %
Date: 2022-11-19 15:00:39 Functions: 8 56 14.3 %

          Line data    Source code
       1             : // Copyright (C) 2013 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.extensions.api.changes;
      16             : 
      17             : import com.google.common.collect.ListMultimap;
      18             : import com.google.gerrit.common.Nullable;
      19             : import com.google.gerrit.extensions.client.ArchiveFormat;
      20             : import com.google.gerrit.extensions.client.SubmitType;
      21             : import com.google.gerrit.extensions.common.ActionInfo;
      22             : import com.google.gerrit.extensions.common.ApplyProvidedFixInput;
      23             : import com.google.gerrit.extensions.common.ApprovalInfo;
      24             : import com.google.gerrit.extensions.common.ChangeInfo;
      25             : import com.google.gerrit.extensions.common.CommentInfo;
      26             : import com.google.gerrit.extensions.common.CommitInfo;
      27             : import com.google.gerrit.extensions.common.DiffInfo;
      28             : import com.google.gerrit.extensions.common.EditInfo;
      29             : import com.google.gerrit.extensions.common.FileInfo;
      30             : import com.google.gerrit.extensions.common.MergeableInfo;
      31             : import com.google.gerrit.extensions.common.RobotCommentInfo;
      32             : import com.google.gerrit.extensions.common.TestSubmitRuleInfo;
      33             : import com.google.gerrit.extensions.common.TestSubmitRuleInput;
      34             : import com.google.gerrit.extensions.restapi.BinaryResult;
      35             : import com.google.gerrit.extensions.restapi.NotImplementedException;
      36             : import com.google.gerrit.extensions.restapi.RestApiException;
      37             : import java.util.EnumSet;
      38             : import java.util.List;
      39             : import java.util.Map;
      40             : import java.util.Set;
      41             : 
      42             : public interface RevisionApi {
      43             :   String description() throws RestApiException;
      44             : 
      45             :   void description(String description) throws RestApiException;
      46             : 
      47             :   ReviewResult review(ReviewInput in) throws RestApiException;
      48             : 
      49             :   default ChangeInfo submit() throws RestApiException {
      50          43 :     SubmitInput in = new SubmitInput();
      51          43 :     return submit(in);
      52             :   }
      53             : 
      54             :   ChangeInfo submit(SubmitInput in) throws RestApiException;
      55             : 
      56             :   ChangeApi cherryPick(CherryPickInput in) throws RestApiException;
      57             : 
      58             :   ChangeInfo cherryPickAsInfo(CherryPickInput in) throws RestApiException;
      59             : 
      60             :   default ChangeApi rebase() throws RestApiException {
      61           5 :     RebaseInput in = new RebaseInput();
      62           5 :     return rebase(in);
      63             :   }
      64             : 
      65             :   ChangeApi rebase(RebaseInput in) throws RestApiException;
      66             : 
      67             :   ChangeInfo rebaseAsInfo(RebaseInput in) throws RestApiException;
      68             : 
      69             :   boolean canRebase() throws RestApiException;
      70             : 
      71             :   RevisionReviewerApi reviewer(String id) throws RestApiException;
      72             : 
      73             :   void setReviewed(String path, boolean reviewed) throws RestApiException;
      74             : 
      75             :   Set<String> reviewed() throws RestApiException;
      76             : 
      77             :   default Map<String, FileInfo> files() throws RestApiException {
      78           7 :     return files(null);
      79             :   }
      80             : 
      81             :   Map<String, FileInfo> files(@Nullable String base) throws RestApiException;
      82             : 
      83             :   Map<String, FileInfo> files(int parentNum) throws RestApiException;
      84             : 
      85             :   List<String> queryFiles(String query) throws RestApiException;
      86             : 
      87             :   FileApi file(String path);
      88             : 
      89             :   CommitInfo commit(boolean addLinks) throws RestApiException;
      90             : 
      91             :   MergeableInfo mergeable() throws RestApiException;
      92             : 
      93             :   MergeableInfo mergeableOtherBranches() throws RestApiException;
      94             : 
      95             :   Map<String, List<CommentInfo>> comments() throws RestApiException;
      96             : 
      97             :   Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException;
      98             : 
      99             :   Map<String, List<CommentInfo>> drafts() throws RestApiException;
     100             : 
     101             :   List<CommentInfo> commentsAsList() throws RestApiException;
     102             : 
     103             :   List<CommentInfo> draftsAsList() throws RestApiException;
     104             : 
     105             :   List<RobotCommentInfo> robotCommentsAsList() throws RestApiException;
     106             : 
     107             :   Map<String, List<CommentInfo>> portedComments() throws RestApiException;
     108             : 
     109             :   Map<String, List<CommentInfo>> portedDrafts() throws RestApiException;
     110             : 
     111             :   /**
     112             :    * Applies the indicated fix by creating a new change edit or integrating the fix with the
     113             :    * existing change edit. If no change edit exists before this call, the fix must refer to the
     114             :    * current patch set. If a change edit exists, the fix must refer to the patch set on which the
     115             :    * change edit is based.
     116             :    *
     117             :    * @param fixId the ID of the fix which should be applied
     118             :    * @throws RestApiException if the fix couldn't be applied
     119             :    */
     120             :   EditInfo applyFix(String fixId) throws RestApiException;
     121             : 
     122             :   /**
     123             :    * Applies fix similar to {@code applyFix} method. Instead of using a fix stored in the server,
     124             :    * this applies the fix provided in {@code ApplyProvidedFixInput}
     125             :    *
     126             :    * @param applyProvidedFixInput The fix(es) to apply to a new change edit.
     127             :    * @throws RestApiException if the fix couldn't be applied.
     128             :    */
     129             :   EditInfo applyFix(ApplyProvidedFixInput applyProvidedFixInput) throws RestApiException;
     130             : 
     131             :   Map<String, DiffInfo> getFixPreview(String fixId) throws RestApiException;
     132             : 
     133             :   Map<String, DiffInfo> getFixPreview(ApplyProvidedFixInput applyProvidedFixInput)
     134             :       throws RestApiException;
     135             : 
     136             :   DraftApi createDraft(DraftInput in) throws RestApiException;
     137             : 
     138             :   DraftApi draft(String id) throws RestApiException;
     139             : 
     140             :   CommentApi comment(String id) throws RestApiException;
     141             : 
     142             :   RobotCommentApi robotComment(String id) throws RestApiException;
     143             : 
     144             :   String etag() throws RestApiException;
     145             : 
     146             :   /** Returns patch of revision. */
     147             :   BinaryResult patch() throws RestApiException;
     148             : 
     149             :   BinaryResult patch(String path) throws RestApiException;
     150             : 
     151             :   Map<String, ActionInfo> actions() throws RestApiException;
     152             : 
     153             :   SubmitType submitType() throws RestApiException;
     154             : 
     155             :   SubmitType testSubmitType(TestSubmitRuleInput in) throws RestApiException;
     156             : 
     157             :   TestSubmitRuleInfo testSubmitRule(TestSubmitRuleInput in) throws RestApiException;
     158             : 
     159             :   MergeListRequest getMergeList() throws RestApiException;
     160             : 
     161             :   RelatedChangesInfo related() throws RestApiException;
     162             : 
     163             :   RelatedChangesInfo related(EnumSet<GetRelatedOption> listOptions) throws RestApiException;
     164             : 
     165             :   /** Returns votes on the revision. */
     166             :   ListMultimap<String, ApprovalInfo> votes() throws RestApiException;
     167             : 
     168             :   /**
     169             :    * Retrieves the revision as an archive.
     170             :    *
     171             :    * @param format the format of the archive
     172             :    * @return the archive as {@link BinaryResult}
     173             :    */
     174             :   BinaryResult getArchive(ArchiveFormat format) throws RestApiException;
     175             : 
     176           1 :   abstract class MergeListRequest {
     177             :     private boolean addLinks;
     178           1 :     private int uninterestingParent = 1;
     179             : 
     180             :     public abstract List<CommitInfo> get() throws RestApiException;
     181             : 
     182             :     public MergeListRequest withLinks() {
     183           0 :       this.addLinks = true;
     184           0 :       return this;
     185             :     }
     186             : 
     187             :     public MergeListRequest withUninterestingParent(int uninterestingParent) {
     188           1 :       this.uninterestingParent = uninterestingParent;
     189           1 :       return this;
     190             :     }
     191             : 
     192             :     public boolean getAddLinks() {
     193           1 :       return addLinks;
     194             :     }
     195             : 
     196             :     public int getUninterestingParent() {
     197           1 :       return uninterestingParent;
     198             :     }
     199             :   }
     200             : 
     201             :   /**
     202             :    * A default implementation which allows source compatibility when adding new methods to the
     203             :    * interface.
     204             :    */
     205          79 :   class NotImplemented implements RevisionApi {
     206             :     @Override
     207             :     public ReviewResult review(ReviewInput in) throws RestApiException {
     208           0 :       throw new NotImplementedException();
     209             :     }
     210             : 
     211             :     @Override
     212             :     public ChangeInfo submit(SubmitInput in) throws RestApiException {
     213           0 :       throw new NotImplementedException();
     214             :     }
     215             : 
     216             :     @Override
     217             :     public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
     218           0 :       throw new NotImplementedException();
     219             :     }
     220             : 
     221             :     @Override
     222             :     public ChangeInfo cherryPickAsInfo(CherryPickInput in) throws RestApiException {
     223           0 :       throw new NotImplementedException();
     224             :     }
     225             : 
     226             :     @Override
     227             :     public ChangeApi rebase(RebaseInput in) throws RestApiException {
     228           0 :       throw new NotImplementedException();
     229             :     }
     230             : 
     231             :     @Override
     232             :     public ChangeInfo rebaseAsInfo(RebaseInput in) throws RestApiException {
     233           0 :       throw new NotImplementedException();
     234             :     }
     235             : 
     236             :     @Override
     237             :     public boolean canRebase() throws RestApiException {
     238           0 :       throw new NotImplementedException();
     239             :     }
     240             : 
     241             :     @Override
     242             :     public RevisionReviewerApi reviewer(String id) throws RestApiException {
     243           0 :       throw new NotImplementedException();
     244             :     }
     245             : 
     246             :     @Override
     247             :     public void setReviewed(String path, boolean reviewed) throws RestApiException {
     248           0 :       throw new NotImplementedException();
     249             :     }
     250             : 
     251             :     @Override
     252             :     public Set<String> reviewed() throws RestApiException {
     253           0 :       throw new NotImplementedException();
     254             :     }
     255             : 
     256             :     @Override
     257             :     public MergeableInfo mergeable() throws RestApiException {
     258           0 :       throw new NotImplementedException();
     259             :     }
     260             : 
     261             :     @Override
     262             :     public MergeableInfo mergeableOtherBranches() throws RestApiException {
     263           0 :       throw new NotImplementedException();
     264             :     }
     265             : 
     266             :     @Override
     267             :     public Map<String, FileInfo> files(String base) throws RestApiException {
     268           0 :       throw new NotImplementedException();
     269             :     }
     270             : 
     271             :     @Override
     272             :     public Map<String, FileInfo> files(int parentNum) throws RestApiException {
     273           0 :       throw new NotImplementedException();
     274             :     }
     275             : 
     276             :     @Override
     277             :     public List<String> queryFiles(String query) throws RestApiException {
     278           0 :       throw new NotImplementedException();
     279             :     }
     280             : 
     281             :     @Override
     282             :     public FileApi file(String path) {
     283           0 :       throw new NotImplementedException();
     284             :     }
     285             : 
     286             :     @Override
     287             :     public CommitInfo commit(boolean addLinks) throws RestApiException {
     288           0 :       throw new NotImplementedException();
     289             :     }
     290             : 
     291             :     @Override
     292             :     public Map<String, List<CommentInfo>> comments() throws RestApiException {
     293           0 :       throw new NotImplementedException();
     294             :     }
     295             : 
     296             :     @Override
     297             :     public Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException {
     298           0 :       throw new NotImplementedException();
     299             :     }
     300             : 
     301             :     @Override
     302             :     public List<CommentInfo> commentsAsList() throws RestApiException {
     303           0 :       throw new NotImplementedException();
     304             :     }
     305             : 
     306             :     @Override
     307             :     public List<CommentInfo> draftsAsList() throws RestApiException {
     308           0 :       throw new NotImplementedException();
     309             :     }
     310             : 
     311             :     @Override
     312             :     public List<RobotCommentInfo> robotCommentsAsList() throws RestApiException {
     313           0 :       throw new NotImplementedException();
     314             :     }
     315             : 
     316             :     @Override
     317             :     public Map<String, List<CommentInfo>> portedComments() throws RestApiException {
     318           0 :       throw new NotImplementedException();
     319             :     }
     320             : 
     321             :     @Override
     322             :     public Map<String, List<CommentInfo>> portedDrafts() throws RestApiException {
     323           0 :       throw new NotImplementedException();
     324             :     }
     325             : 
     326             :     @Override
     327             :     public EditInfo applyFix(String fixId) throws RestApiException {
     328           0 :       throw new NotImplementedException();
     329             :     }
     330             : 
     331             :     @Override
     332             :     public EditInfo applyFix(ApplyProvidedFixInput applyProvidedFixInput) throws RestApiException {
     333           0 :       throw new NotImplementedException();
     334             :     }
     335             : 
     336             :     @Override
     337             :     public Map<String, DiffInfo> getFixPreview(String fixId) throws RestApiException {
     338           0 :       throw new NotImplementedException();
     339             :     }
     340             : 
     341             :     @Override
     342             :     public Map<String, DiffInfo> getFixPreview(ApplyProvidedFixInput applyProvidedFixInput)
     343             :         throws RestApiException {
     344           0 :       throw new NotImplementedException();
     345             :     }
     346             : 
     347             :     @Override
     348             :     public Map<String, List<CommentInfo>> drafts() throws RestApiException {
     349           0 :       throw new NotImplementedException();
     350             :     }
     351             : 
     352             :     @Override
     353             :     public DraftApi createDraft(DraftInput in) throws RestApiException {
     354           0 :       throw new NotImplementedException();
     355             :     }
     356             : 
     357             :     @Override
     358             :     public DraftApi draft(String id) throws RestApiException {
     359           0 :       throw new NotImplementedException();
     360             :     }
     361             : 
     362             :     @Override
     363             :     public CommentApi comment(String id) throws RestApiException {
     364           0 :       throw new NotImplementedException();
     365             :     }
     366             : 
     367             :     @Override
     368             :     public RobotCommentApi robotComment(String id) throws RestApiException {
     369           0 :       throw new NotImplementedException();
     370             :     }
     371             : 
     372             :     @Override
     373             :     public BinaryResult patch() throws RestApiException {
     374           0 :       throw new NotImplementedException();
     375             :     }
     376             : 
     377             :     @Override
     378             :     public BinaryResult patch(String path) throws RestApiException {
     379           0 :       throw new NotImplementedException();
     380             :     }
     381             : 
     382             :     @Override
     383             :     public Map<String, ActionInfo> actions() throws RestApiException {
     384           0 :       throw new NotImplementedException();
     385             :     }
     386             : 
     387             :     @Override
     388             :     public SubmitType submitType() throws RestApiException {
     389           0 :       throw new NotImplementedException();
     390             :     }
     391             : 
     392             :     @Override
     393             :     public SubmitType testSubmitType(TestSubmitRuleInput in) throws RestApiException {
     394           0 :       throw new NotImplementedException();
     395             :     }
     396             : 
     397             :     @Override
     398             :     public TestSubmitRuleInfo testSubmitRule(TestSubmitRuleInput in) throws RestApiException {
     399           0 :       throw new NotImplementedException();
     400             :     }
     401             : 
     402             :     @Override
     403             :     public MergeListRequest getMergeList() throws RestApiException {
     404           0 :       throw new NotImplementedException();
     405             :     }
     406             : 
     407             :     @Override
     408             :     public RelatedChangesInfo related() throws RestApiException {
     409           0 :       throw new NotImplementedException();
     410             :     }
     411             : 
     412             :     @Override
     413             :     public RelatedChangesInfo related(EnumSet<GetRelatedOption> options) throws RestApiException {
     414           0 :       throw new NotImplementedException();
     415             :     }
     416             : 
     417             :     @Override
     418             :     public ListMultimap<String, ApprovalInfo> votes() throws RestApiException {
     419           0 :       throw new NotImplementedException();
     420             :     }
     421             : 
     422             :     @Override
     423             :     public void description(String description) throws RestApiException {
     424           0 :       throw new NotImplementedException();
     425             :     }
     426             : 
     427             :     @Override
     428             :     public String description() throws RestApiException {
     429           0 :       throw new NotImplementedException();
     430             :     }
     431             : 
     432             :     @Override
     433             :     public String etag() throws RestApiException {
     434           0 :       throw new NotImplementedException();
     435             :     }
     436             : 
     437             :     @Override
     438             :     public BinaryResult getArchive(ArchiveFormat format) throws RestApiException {
     439           0 :       throw new NotImplementedException();
     440             :     }
     441             :   }
     442             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750