LCOV - code coverage report
Current view: top level - server/project/testing - TestLabels.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 19 19 100.0 %
Date: 2022-11-19 15:00:39 Functions: 7 7 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.project.testing;
      16             : 
      17             : import com.google.gerrit.entities.LabelFunction;
      18             : import com.google.gerrit.entities.LabelId;
      19             : import com.google.gerrit.entities.LabelType;
      20             : import com.google.gerrit.entities.LabelValue;
      21             : import java.util.Arrays;
      22             : import java.util.Optional;
      23             : 
      24             : public class TestLabels {
      25             :   public static final String CODE_REVIEW_LABEL_DESCRIPTION = "Code review label description";
      26             :   public static final String VERIFIED_LABEL_DESCRIPTION = "Verified label description";
      27             : 
      28             :   public static LabelType codeReview() {
      29          16 :     return label(
      30             :         LabelId.CODE_REVIEW,
      31             :         CODE_REVIEW_LABEL_DESCRIPTION,
      32          16 :         value(2, "Looks good to me, approved"),
      33          16 :         value(1, "Looks good to me, but someone else must approve"),
      34          16 :         value(0, "No score"),
      35          16 :         value(-1, "I would prefer this is not submitted as is"),
      36          16 :         value(-2, "This shall not be submitted"));
      37             :   }
      38             : 
      39             :   public static LabelType verified() {
      40           7 :     return label(
      41             :         LabelId.VERIFIED,
      42             :         VERIFIED_LABEL_DESCRIPTION,
      43           7 :         value(1, LabelId.VERIFIED),
      44           7 :         value(0, "No score"),
      45           7 :         value(-1, "Fails"));
      46             :   }
      47             : 
      48             :   public static LabelType patchSetLock() {
      49           4 :     LabelType.Builder label =
      50           4 :         labelBuilder(
      51           4 :             "Patch-Set-Lock", value(1, "Patch Set Locked"), value(0, "Patch Set Unlocked"));
      52           4 :     label.setFunction(LabelFunction.PATCH_SET_LOCK);
      53           4 :     return label.build();
      54             :   }
      55             : 
      56             :   public static LabelValue value(int value, String text) {
      57          31 :     return LabelValue.create((short) value, text);
      58             :   }
      59             : 
      60             :   public static LabelType label(String name, String description, LabelValue... values) {
      61          17 :     return labelBuilder(name, values).setDescription(Optional.of(description)).build();
      62             :   }
      63             : 
      64             :   public static LabelType label(String name, LabelValue... values) {
      65          19 :     return labelBuilder(name, values).build();
      66             :   }
      67             : 
      68             :   public static LabelType.Builder labelBuilder(String name, LabelValue... values) {
      69          31 :     return LabelType.builder(name, Arrays.asList(values));
      70             :   }
      71             : 
      72             :   private TestLabels() {}
      73             : }

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