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

          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.server.notedb;
      16             : 
      17             : import com.google.common.cache.Cache;
      18             : import com.google.common.cache.CacheBuilder;
      19             : import com.google.gerrit.extensions.config.FactoryModule;
      20             : import com.google.inject.TypeLiteral;
      21             : import com.google.inject.name.Names;
      22             : 
      23             : public class NoteDbModule extends FactoryModule {
      24             :   private final boolean useTestBindings;
      25             : 
      26             :   static NoteDbModule forTest() {
      27           1 :     return new NoteDbModule(true);
      28             :   }
      29             : 
      30             :   public NoteDbModule() {
      31         152 :     this(false);
      32         152 :   }
      33             : 
      34         152 :   private NoteDbModule(boolean useTestBindings) {
      35         152 :     this.useTestBindings = useTestBindings;
      36         152 :   }
      37             : 
      38             :   @Override
      39             :   public void configure() {
      40         152 :     factory(ChangeDraftUpdate.Factory.class);
      41         152 :     factory(ChangeUpdate.Factory.class);
      42         152 :     factory(DeleteCommentRewriter.Factory.class);
      43         152 :     factory(DraftCommentNotes.Factory.class);
      44         152 :     factory(NoteDbUpdateManager.Factory.class);
      45         152 :     factory(RobotCommentNotes.Factory.class);
      46         152 :     factory(RobotCommentUpdate.Factory.class);
      47             : 
      48         152 :     if (!useTestBindings) {
      49         152 :       install(ChangeNotesCache.module());
      50             :     } else {
      51           1 :       bind(new TypeLiteral<Cache<ChangeNotesCache.Key, ChangeNotesState>>() {})
      52           1 :           .annotatedWith(Names.named(ChangeNotesCache.CACHE_NAME))
      53           1 :           .toInstance(CacheBuilder.newBuilder().build());
      54             :     }
      55         152 :   }
      56             : }

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