LCOV - code coverage report
Current view: top level - index/testing - FakeIndexModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 9 10 90.0 %
Date: 2022-11-19 15:00:39 Functions: 8 9 88.9 %

          Line data    Source code
       1             : // Copyright (C) 2021 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.index.testing;
      16             : 
      17             : import com.google.common.collect.ImmutableMap;
      18             : import com.google.gerrit.index.project.ProjectIndex;
      19             : import com.google.gerrit.server.index.AbstractIndexModule;
      20             : import com.google.gerrit.server.index.VersionManager;
      21             : import com.google.gerrit.server.index.account.AccountIndex;
      22             : import com.google.gerrit.server.index.change.ChangeIndex;
      23             : import com.google.gerrit.server.index.group.GroupIndex;
      24             : import java.util.Map;
      25             : 
      26             : /** Module to bind {@link FakeIndexModule}. */
      27             : public class FakeIndexModule extends AbstractIndexModule {
      28             :   public static FakeIndexModule singleVersionAllLatest(int threads, boolean secondary) {
      29           0 :     return new FakeIndexModule(ImmutableMap.of(), threads, secondary);
      30             :   }
      31             : 
      32             :   public static FakeIndexModule singleVersionWithExplicitVersions(
      33             :       Map<String, Integer> versions, int threads, boolean secondary) {
      34          26 :     return new FakeIndexModule(versions, threads, secondary);
      35             :   }
      36             : 
      37             :   public static FakeIndexModule latestVersion(boolean secondary) {
      38         138 :     return new FakeIndexModule(null, -1 /* direct executor */, secondary);
      39             :   }
      40             : 
      41             :   private FakeIndexModule(Map<String, Integer> singleVersions, int threads, boolean secondary) {
      42         147 :     super(singleVersions, threads, secondary);
      43         147 :   }
      44             : 
      45             :   @Override
      46             :   protected Class<? extends AccountIndex> getAccountIndex() {
      47         147 :     return AbstractFakeIndex.FakeAccountIndex.class;
      48             :   }
      49             : 
      50             :   @Override
      51             :   protected Class<? extends ChangeIndex> getChangeIndex() {
      52         147 :     return AbstractFakeIndex.FakeChangeIndex.class;
      53             :   }
      54             : 
      55             :   @Override
      56             :   protected Class<? extends GroupIndex> getGroupIndex() {
      57         147 :     return AbstractFakeIndex.FakeGroupIndex.class;
      58             :   }
      59             : 
      60             :   @Override
      61             :   protected Class<? extends ProjectIndex> getProjectIndex() {
      62         147 :     return AbstractFakeIndex.FakeProjectIndex.class;
      63             :   }
      64             : 
      65             :   @Override
      66             :   protected Class<? extends VersionManager> getVersionManager() {
      67         138 :     return FakeIndexVersionManager.class;
      68             :   }
      69             : }

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