LCOV - code coverage report
Current view: top level - server/restapi/change - ChangeRestApiModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 161 161 100.0 %
Date: 2022-11-19 15:00:39 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2012 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.server.restapi.change;
      16             : 
      17             : import static com.google.gerrit.server.change.AttentionSetEntryResource.ATTENTION_SET_ENTRY_KIND;
      18             : import static com.google.gerrit.server.change.ChangeEditResource.CHANGE_EDIT_KIND;
      19             : import static com.google.gerrit.server.change.ChangeMessageResource.CHANGE_MESSAGE_KIND;
      20             : import static com.google.gerrit.server.change.ChangeResource.CHANGE_KIND;
      21             : import static com.google.gerrit.server.change.DraftCommentResource.DRAFT_COMMENT_KIND;
      22             : import static com.google.gerrit.server.change.FileResource.FILE_KIND;
      23             : import static com.google.gerrit.server.change.FixResource.FIX_KIND;
      24             : import static com.google.gerrit.server.change.HumanCommentResource.COMMENT_KIND;
      25             : import static com.google.gerrit.server.change.ReviewerResource.REVIEWER_KIND;
      26             : import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
      27             : import static com.google.gerrit.server.change.RobotCommentResource.ROBOT_COMMENT_KIND;
      28             : import static com.google.gerrit.server.change.VoteResource.VOTE_KIND;
      29             : 
      30             : import com.google.gerrit.extensions.registration.DynamicMap;
      31             : import com.google.gerrit.extensions.restapi.RestApiModule;
      32             : import com.google.gerrit.server.account.AccountLoader;
      33             : import com.google.gerrit.server.change.AddReviewersOp;
      34             : import com.google.gerrit.server.change.AddToAttentionSetOp;
      35             : import com.google.gerrit.server.change.ChangeInserter;
      36             : import com.google.gerrit.server.change.ChangeResource;
      37             : import com.google.gerrit.server.change.DeleteChangeOp;
      38             : import com.google.gerrit.server.change.DeleteReviewerByEmailOp;
      39             : import com.google.gerrit.server.change.DeleteReviewerOp;
      40             : import com.google.gerrit.server.change.EmailReviewComments;
      41             : import com.google.gerrit.server.change.PatchSetInserter;
      42             : import com.google.gerrit.server.change.RebaseChangeOp;
      43             : import com.google.gerrit.server.change.RemoveFromAttentionSetOp;
      44             : import com.google.gerrit.server.change.ReviewerResource;
      45             : import com.google.gerrit.server.change.SetAssigneeOp;
      46             : import com.google.gerrit.server.change.SetCherryPickOp;
      47             : import com.google.gerrit.server.change.SetHashtagsOp;
      48             : import com.google.gerrit.server.change.SetPrivateOp;
      49             : import com.google.gerrit.server.change.SetTopicOp;
      50             : import com.google.gerrit.server.change.WorkInProgressOp;
      51             : import com.google.gerrit.server.comment.CommentContextLoader;
      52             : import com.google.gerrit.server.restapi.change.Reviewed.DeleteReviewed;
      53             : import com.google.gerrit.server.restapi.change.Reviewed.PutReviewed;
      54             : import com.google.gerrit.server.util.AttentionSetEmail;
      55             : 
      56         152 : public class ChangeRestApiModule extends RestApiModule {
      57             :   @Override
      58             :   protected void configure() {
      59         152 :     bind(ChangesCollection.class);
      60         152 :     bind(Revisions.class);
      61         152 :     bind(Reviewers.class);
      62         152 :     bind(RevisionReviewers.class);
      63         152 :     bind(DraftComments.class);
      64         152 :     bind(Comments.class);
      65         152 :     bind(RobotComments.class);
      66         152 :     bind(Fixes.class);
      67         152 :     bind(Files.class);
      68         152 :     bind(Votes.class);
      69             : 
      70         152 :     DynamicMap.mapOf(binder(), CHANGE_KIND);
      71         152 :     DynamicMap.mapOf(binder(), COMMENT_KIND);
      72         152 :     DynamicMap.mapOf(binder(), ROBOT_COMMENT_KIND);
      73         152 :     DynamicMap.mapOf(binder(), FIX_KIND);
      74         152 :     DynamicMap.mapOf(binder(), DRAFT_COMMENT_KIND);
      75         152 :     DynamicMap.mapOf(binder(), FILE_KIND);
      76         152 :     DynamicMap.mapOf(binder(), REVIEWER_KIND);
      77         152 :     DynamicMap.mapOf(binder(), REVISION_KIND);
      78         152 :     DynamicMap.mapOf(binder(), CHANGE_EDIT_KIND);
      79         152 :     DynamicMap.mapOf(binder(), VOTE_KIND);
      80         152 :     DynamicMap.mapOf(binder(), CHANGE_MESSAGE_KIND);
      81         152 :     DynamicMap.mapOf(binder(), ATTENTION_SET_ENTRY_KIND);
      82             : 
      83         152 :     postOnCollection(CHANGE_KIND).to(CreateChange.class);
      84         152 :     get(CHANGE_KIND).to(GetChange.class);
      85         152 :     get(CHANGE_KIND, "meta_diff").to(GetMetaDiff.class);
      86         152 :     post(CHANGE_KIND, "merge").to(CreateMergePatchSet.class);
      87         152 :     get(CHANGE_KIND, "detail").to(GetDetail.class);
      88         152 :     get(CHANGE_KIND, "topic").to(GetTopic.class);
      89         152 :     get(CHANGE_KIND, "in").to(ChangeIncludedIn.class);
      90         152 :     child(CHANGE_KIND, "attention").to(AttentionSet.class);
      91         152 :     delete(ATTENTION_SET_ENTRY_KIND).to(RemoveFromAttentionSet.class);
      92         152 :     post(ATTENTION_SET_ENTRY_KIND, "delete").to(RemoveFromAttentionSet.class);
      93         152 :     postOnCollection(ATTENTION_SET_ENTRY_KIND).to(AddToAttentionSet.class);
      94         152 :     get(CHANGE_KIND, "assignee").to(GetAssignee.class);
      95         152 :     get(CHANGE_KIND, "past_assignees").to(GetPastAssignees.class);
      96         152 :     put(CHANGE_KIND, "assignee").to(PutAssignee.class);
      97         152 :     delete(CHANGE_KIND, "assignee").to(DeleteAssignee.class);
      98         152 :     get(CHANGE_KIND, "hashtags").to(GetHashtags.class);
      99         152 :     get(CHANGE_KIND, "comments").to(ListChangeComments.class);
     100         152 :     get(CHANGE_KIND, "robotcomments").to(ListChangeRobotComments.class);
     101         152 :     get(CHANGE_KIND, "drafts").to(ListChangeDrafts.class);
     102         152 :     get(CHANGE_KIND, "check").to(Check.class);
     103         152 :     get(CHANGE_KIND, "pure_revert").to(GetPureRevert.class);
     104         152 :     post(CHANGE_KIND, "check").to(Check.class);
     105         152 :     put(CHANGE_KIND, "topic").to(PutTopic.class);
     106         152 :     delete(CHANGE_KIND, "topic").to(PutTopic.class);
     107         152 :     delete(CHANGE_KIND).to(DeleteChange.class);
     108         152 :     post(CHANGE_KIND, "abandon").to(Abandon.class);
     109         152 :     post(CHANGE_KIND, "hashtags").to(PostHashtags.class);
     110         152 :     post(CHANGE_KIND, "restore").to(Restore.class);
     111         152 :     post(CHANGE_KIND, "revert").to(Revert.class);
     112         152 :     post(CHANGE_KIND, "revert_submission").to(RevertSubmission.class);
     113         152 :     post(CHANGE_KIND, "submit").to(Submit.CurrentRevision.class);
     114         152 :     get(CHANGE_KIND, "submitted_together").to(SubmittedTogether.class);
     115         152 :     post(CHANGE_KIND, "rebase").to(Rebase.CurrentRevision.class);
     116         152 :     post(CHANGE_KIND, "index").to(Index.class);
     117         152 :     post(CHANGE_KIND, "move").to(Move.class);
     118         152 :     post(CHANGE_KIND, "private").to(PostPrivate.class);
     119         152 :     post(CHANGE_KIND, "private.delete").to(DeletePrivateByPost.class);
     120         152 :     delete(CHANGE_KIND, "private").to(DeletePrivate.class);
     121         152 :     post(CHANGE_KIND, "wip").to(SetWorkInProgress.class);
     122         152 :     post(CHANGE_KIND, "ready").to(SetReadyForReview.class);
     123         152 :     put(CHANGE_KIND, "message").to(PutMessage.class);
     124         152 :     post(CHANGE_KIND, "check.submit_requirement").to(CheckSubmitRequirement.class);
     125         152 :     post(CHANGE_KIND, "patch:apply").to(ApplyPatch.class);
     126             : 
     127         152 :     get(CHANGE_KIND, "suggest_reviewers").to(SuggestChangeReviewers.class);
     128         152 :     child(CHANGE_KIND, "reviewers").to(Reviewers.class);
     129         152 :     postOnCollection(REVIEWER_KIND).to(PostReviewers.class);
     130         152 :     get(REVIEWER_KIND).to(GetReviewer.class);
     131         152 :     delete(REVIEWER_KIND).to(DeleteReviewer.class);
     132         152 :     post(REVIEWER_KIND, "delete").to(DeleteReviewer.class);
     133         152 :     child(REVIEWER_KIND, "votes").to(Votes.class);
     134         152 :     delete(VOTE_KIND).to(DeleteVote.class);
     135         152 :     post(VOTE_KIND, "delete").to(DeleteVote.class);
     136             : 
     137         152 :     child(CHANGE_KIND, "revisions").to(Revisions.class);
     138         152 :     get(REVISION_KIND, "actions").to(GetRevisionActions.class);
     139         152 :     post(REVISION_KIND, "cherrypick").to(CherryPick.class);
     140         152 :     get(REVISION_KIND, "commit").to(GetCommit.class);
     141         152 :     get(REVISION_KIND, "mergeable").to(Mergeable.class);
     142         152 :     get(REVISION_KIND, "related").to(GetRelated.class);
     143         152 :     get(REVISION_KIND, "review").to(GetReview.class);
     144         152 :     post(REVISION_KIND, "review").to(PostReview.class);
     145         152 :     post(REVISION_KIND, "submit").to(Submit.class);
     146         152 :     post(REVISION_KIND, "rebase").to(Rebase.class);
     147         152 :     put(REVISION_KIND, "description").to(PutDescription.class);
     148         152 :     get(REVISION_KIND, "description").to(GetDescription.class);
     149         152 :     get(REVISION_KIND, "patch").to(GetPatch.class);
     150         152 :     get(REVISION_KIND, "submit_type").to(TestSubmitType.Get.class);
     151         152 :     post(REVISION_KIND, "test.submit_rule").to(TestSubmitRule.class);
     152         152 :     post(REVISION_KIND, "test.submit_type").to(TestSubmitType.class);
     153         152 :     get(REVISION_KIND, "archive").to(GetArchive.class);
     154         152 :     get(REVISION_KIND, "mergelist").to(GetMergeList.class);
     155             : 
     156         152 :     child(REVISION_KIND, "reviewers").to(RevisionReviewers.class);
     157             : 
     158         152 :     child(REVISION_KIND, "drafts").to(DraftComments.class);
     159         152 :     put(REVISION_KIND, "drafts").to(CreateDraftComment.class);
     160         152 :     get(DRAFT_COMMENT_KIND).to(GetDraftComment.class);
     161         152 :     put(DRAFT_COMMENT_KIND).to(PutDraftComment.class);
     162         152 :     delete(DRAFT_COMMENT_KIND).to(DeleteDraftComment.class);
     163             : 
     164         152 :     child(REVISION_KIND, "comments").to(Comments.class);
     165         152 :     get(COMMENT_KIND).to(GetComment.class);
     166         152 :     delete(COMMENT_KIND).to(DeleteComment.class);
     167         152 :     post(COMMENT_KIND, "delete").to(DeleteComment.class);
     168             : 
     169         152 :     child(REVISION_KIND, "robotcomments").to(RobotComments.class);
     170         152 :     get(ROBOT_COMMENT_KIND).to(GetRobotComment.class);
     171         152 :     child(REVISION_KIND, "fixes").to(Fixes.class);
     172         152 :     post(FIX_KIND, "apply").to(ApplyStoredFix.class);
     173         152 :     get(FIX_KIND, "preview").to(PreviewFix.Stored.class);
     174         152 :     post(REVISION_KIND, "fix:apply").to(ApplyProvidedFix.class);
     175         152 :     post(REVISION_KIND, "fix:preview").to(PreviewFix.Provided.class);
     176             : 
     177         152 :     get(REVISION_KIND, "ported_comments").to(ListPortedComments.class);
     178         152 :     get(REVISION_KIND, "ported_drafts").to(ListPortedDrafts.class);
     179             : 
     180         152 :     child(REVISION_KIND, "files").to(Files.class);
     181         152 :     put(FILE_KIND, "reviewed").to(PutReviewed.class);
     182         152 :     delete(FILE_KIND, "reviewed").to(DeleteReviewed.class);
     183         152 :     get(FILE_KIND, "content").to(GetContent.class);
     184         152 :     get(FILE_KIND, "download").to(DownloadContent.class);
     185         152 :     get(FILE_KIND, "diff").to(GetDiff.class);
     186         152 :     get(FILE_KIND, "blame").to(GetBlame.class);
     187             : 
     188         152 :     child(CHANGE_KIND, "edit").to(ChangeEdits.class);
     189         152 :     create(CHANGE_EDIT_KIND).to(ChangeEdits.Create.class);
     190         152 :     deleteMissing(CHANGE_EDIT_KIND).to(ChangeEdits.DeleteFile.class);
     191         152 :     postOnCollection(CHANGE_EDIT_KIND).to(ChangeEdits.Post.class);
     192         152 :     deleteOnCollection(CHANGE_EDIT_KIND).to(DeleteChangeEdit.class);
     193         152 :     post(CHANGE_KIND, "edit:publish").to(PublishChangeEdit.class);
     194         152 :     post(CHANGE_KIND, "edit:rebase").to(RebaseChangeEdit.class);
     195         152 :     put(CHANGE_KIND, "edit:message").to(ChangeEdits.EditMessage.class);
     196         152 :     get(CHANGE_KIND, "edit:message").to(ChangeEdits.GetMessage.class);
     197         152 :     put(CHANGE_EDIT_KIND, "/").to(ChangeEdits.Put.class);
     198         152 :     delete(CHANGE_EDIT_KIND).to(ChangeEdits.DeleteContent.class);
     199         152 :     get(CHANGE_EDIT_KIND, "/").to(ChangeEdits.Get.class);
     200         152 :     get(CHANGE_EDIT_KIND, "meta").to(ChangeEdits.GetMeta.class);
     201             : 
     202         152 :     child(CHANGE_KIND, "messages").to(ChangeMessages.class);
     203         152 :     get(CHANGE_MESSAGE_KIND).to(GetChangeMessage.class);
     204         152 :     delete(CHANGE_MESSAGE_KIND).to(DeleteChangeMessage.DefaultDeleteChangeMessage.class);
     205         152 :     post(CHANGE_MESSAGE_KIND, "delete").to(DeleteChangeMessage.class);
     206             : 
     207         152 :     factory(AccountLoader.Factory.class);
     208         152 :     factory(ChangeInserter.Factory.class);
     209         152 :     factory(ChangeResource.Factory.class);
     210         152 :     factory(CommentContextLoader.Factory.class);
     211         152 :     factory(DeleteChangeOp.Factory.class);
     212         152 :     factory(DeleteReviewerByEmailOp.Factory.class);
     213         152 :     factory(DeleteReviewerOp.Factory.class);
     214         152 :     factory(DeleteVoteOp.Factory.class);
     215         152 :     factory(EmailReviewComments.Factory.class);
     216         152 :     factory(PatchSetInserter.Factory.class);
     217         152 :     factory(AddReviewersOp.Factory.class);
     218         152 :     factory(PostReviewOp.Factory.class);
     219         152 :     factory(PreviewFix.Factory.class);
     220         152 :     factory(RebaseChangeOp.Factory.class);
     221         152 :     factory(ReviewerResource.Factory.class);
     222         152 :     factory(SetAssigneeOp.Factory.class);
     223         152 :     factory(SetCherryPickOp.Factory.class);
     224         152 :     factory(SetHashtagsOp.Factory.class);
     225         152 :     factory(SetTopicOp.Factory.class);
     226         152 :     factory(SetPrivateOp.Factory.class);
     227         152 :     factory(WorkInProgressOp.Factory.class);
     228         152 :     factory(AddToAttentionSetOp.Factory.class);
     229         152 :     factory(RemoveFromAttentionSetOp.Factory.class);
     230         152 :     factory(AttentionSetEmail.Factory.class);
     231         152 :   }
     232             : }

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