LCOV - code coverage report
Current view: top level - common/data - GarbageCollectionResult.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 17 23 73.9 %
Date: 2022-11-19 15:00:39 Functions: 8 10 80.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.common.data;
      16             : 
      17             : import com.google.gerrit.entities.Project;
      18             : import java.util.ArrayList;
      19             : import java.util.List;
      20             : 
      21             : /** A list of errors occurred during GC. */
      22             : public class GarbageCollectionResult {
      23             :   protected List<GcError> errors;
      24             : 
      25           4 :   public GarbageCollectionResult() {
      26           4 :     errors = new ArrayList<>();
      27           4 :   }
      28             : 
      29             :   public void addError(GcError e) {
      30           1 :     errors.add(e);
      31           1 :   }
      32             : 
      33             :   public List<GcError> getErrors() {
      34           1 :     return errors;
      35             :   }
      36             : 
      37             :   public boolean hasErrors() {
      38           3 :     return !errors.isEmpty();
      39             :   }
      40             : 
      41             :   public static class GcError {
      42           1 :     public enum Type {
      43             :       /** Git garbage collection was already scheduled for this project */
      44           1 :       GC_ALREADY_SCHEDULED,
      45             : 
      46             :       /** The repository was not found. */
      47           1 :       REPOSITORY_NOT_FOUND,
      48             : 
      49             :       /** The Git garbage collection failed. */
      50           1 :       GC_FAILED
      51             :     }
      52             : 
      53             :     protected Type type;
      54             :     protected Project.NameKey projectName;
      55             : 
      56           0 :     protected GcError() {}
      57             : 
      58           1 :     public GcError(Type type, Project.NameKey projectName) {
      59           1 :       this.type = type;
      60           1 :       this.projectName = projectName;
      61           1 :     }
      62             : 
      63             :     public Type getType() {
      64           1 :       return type;
      65             :     }
      66             : 
      67             :     public Project.NameKey getProjectName() {
      68           1 :       return projectName;
      69             :     }
      70             : 
      71             :     @Override
      72             :     public String toString() {
      73           0 :       StringBuilder b = new StringBuilder();
      74           0 :       b.append(type);
      75           0 :       if (projectName != null) {
      76           0 :         b.append(" ").append(projectName);
      77             :       }
      78           0 :       return b.toString();
      79             :     }
      80             :   }
      81             : }

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