LCOV - code coverage report
Current view: top level - server/account - AccountResource.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 23 37 62.2 %
Date: 2022-11-19 15:00:39 Functions: 16 23 69.6 %

          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.account;
      16             : 
      17             : import com.google.gerrit.entities.Change;
      18             : import com.google.gerrit.extensions.restapi.RestResource;
      19             : import com.google.gerrit.extensions.restapi.RestView;
      20             : import com.google.gerrit.server.IdentifiedUser;
      21             : import com.google.gerrit.server.change.ChangeResource;
      22             : import com.google.inject.TypeLiteral;
      23             : import java.util.Set;
      24             : 
      25             : public class AccountResource implements RestResource {
      26         152 :   public static final TypeLiteral<RestView<AccountResource>> ACCOUNT_KIND = new TypeLiteral<>() {};
      27             : 
      28         152 :   public static final TypeLiteral<RestView<Capability>> CAPABILITY_KIND = new TypeLiteral<>() {};
      29             : 
      30         152 :   public static final TypeLiteral<RestView<Email>> EMAIL_KIND = new TypeLiteral<>() {};
      31             : 
      32         152 :   public static final TypeLiteral<RestView<SshKey>> SSH_KEY_KIND = new TypeLiteral<>() {};
      33             : 
      34         152 :   public static final TypeLiteral<RestView<StarredChange>> STARRED_CHANGE_KIND =
      35         152 :       new TypeLiteral<>() {};
      36             : 
      37             :   private final IdentifiedUser user;
      38             : 
      39          36 :   public AccountResource(IdentifiedUser user) {
      40          36 :     this.user = user;
      41          36 :   }
      42             : 
      43             :   public IdentifiedUser getUser() {
      44          35 :     return user;
      45             :   }
      46             : 
      47             :   public static class Capability implements RestResource {
      48             :     private final IdentifiedUser user;
      49             :     private final String capability;
      50             : 
      51           0 :     public Capability(IdentifiedUser user, String capability) {
      52           0 :       this.user = user;
      53           0 :       this.capability = capability;
      54           0 :     }
      55             : 
      56             :     public IdentifiedUser getUser() {
      57           0 :       return user;
      58             :     }
      59             : 
      60             :     public String getCapability() {
      61           0 :       return capability;
      62             :     }
      63             :   }
      64             : 
      65             :   public static class Email extends AccountResource {
      66             :     private final String email;
      67             : 
      68             :     public Email(IdentifiedUser user, String email) {
      69           5 :       super(user);
      70           5 :       this.email = email;
      71           5 :     }
      72             : 
      73             :     public String getEmail() {
      74           3 :       return email;
      75             :     }
      76             :   }
      77             : 
      78             :   public static class SshKey extends AccountResource {
      79             :     private final AccountSshKey sshKey;
      80             : 
      81             :     public SshKey(IdentifiedUser user, AccountSshKey sshKey) {
      82           3 :       super(user);
      83           3 :       this.sshKey = sshKey;
      84           3 :     }
      85             : 
      86             :     public AccountSshKey getSshKey() {
      87           3 :       return sshKey;
      88             :     }
      89             :   }
      90             : 
      91             :   public static class StarredChange extends AccountResource {
      92             :     private final ChangeResource change;
      93             : 
      94             :     public StarredChange(IdentifiedUser user, ChangeResource change) {
      95           3 :       super(user);
      96           3 :       this.change = change;
      97           3 :     }
      98             : 
      99             :     public Change getChange() {
     100           3 :       return change.getChange();
     101             :     }
     102             :   }
     103             : 
     104             :   public static class Star implements RestResource {
     105         152 :     public static final TypeLiteral<RestView<Star>> STAR_KIND = new TypeLiteral<>() {};
     106             : 
     107             :     private final IdentifiedUser user;
     108             :     private final ChangeResource change;
     109             :     private final Set<String> labels;
     110             : 
     111           0 :     public Star(IdentifiedUser user, ChangeResource change, Set<String> labels) {
     112           0 :       this.user = user;
     113           0 :       this.change = change;
     114           0 :       this.labels = labels;
     115           0 :     }
     116             : 
     117             :     public IdentifiedUser getUser() {
     118           0 :       return user;
     119             :     }
     120             : 
     121             :     public Change getChange() {
     122           0 :       return change.getChange();
     123             :     }
     124             : 
     125             :     public Set<String> getLabels() {
     126           0 :       return labels;
     127             :     }
     128             :   }
     129             : }

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