LCOV - code coverage report
Current view: top level - extensions/common - SubmitRequirementExpressionInfo.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 14 17 82.4 %
Date: 2022-11-19 15:00:39 Functions: 3 4 75.0 %

          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.extensions.common;
      16             : 
      17             : import java.util.List;
      18             : import java.util.Objects;
      19             : 
      20             : /**
      21             :  * Result of evaluating a single submit requirement expression. This API entity is populated from
      22             :  * {@link com.google.gerrit.entities.SubmitRequirementExpressionResult}.
      23             :  */
      24         104 : public class SubmitRequirementExpressionInfo {
      25             : 
      26             :   /** Submit requirement expression as a String. */
      27             :   public String expression;
      28             : 
      29             :   /** A boolean indicating if the expression is fulfilled on a change. */
      30             :   public boolean fulfilled;
      31             : 
      32             :   /** A status indicating if the expression is fulfilled, non-fulfilled or not evaluated. */
      33             :   public Status status;
      34             : 
      35             :   /**
      36             :    * A list of all atoms that are passing, for example query "branch:refs/heads/foo and project:bar"
      37             :    * has two atoms: ["branch:refs/heads/foo", "project:bar"].
      38             :    */
      39             :   public List<String> passingAtoms;
      40             : 
      41             :   /**
      42             :    * A list of all atoms that are failing, for example query "branch:refs/heads/foo and project:bar"
      43             :    * has two atoms: ["branch:refs/heads/foo", "project:bar"].
      44             :    */
      45             :   public List<String> failingAtoms;
      46             : 
      47             :   /**
      48             :    * Optional error message. Contains an explanation of why the submit requirement expression failed
      49             :    * during its evaluation.
      50             :    */
      51             :   public String errorMessage;
      52             : 
      53             :   /**
      54             :    * Values in this enum should match with values in {@link
      55             :    * com.google.gerrit.entities.SubmitRequirementExpressionResult.Status}.
      56             :    */
      57         103 :   public enum Status {
      58             :     /** Expression was evaluated and the result was true. */
      59         103 :     PASS,
      60             : 
      61             :     /** Expression was evaluated and the result was false. */
      62         103 :     FAIL,
      63             : 
      64             :     /** An error occurred while evaluating the expression. */
      65         103 :     ERROR,
      66             : 
      67             :     /** Expression was not evaluated. */
      68         103 :     NOT_EVALUATED
      69             :   }
      70             : 
      71             :   @Override
      72             :   public boolean equals(Object o) {
      73           1 :     if (this == o) {
      74           0 :       return true;
      75             :     }
      76           1 :     if (!(o instanceof SubmitRequirementExpressionInfo)) {
      77           0 :       return false;
      78             :     }
      79           1 :     SubmitRequirementExpressionInfo that = (SubmitRequirementExpressionInfo) o;
      80           1 :     return fulfilled == that.fulfilled
      81           1 :         && Objects.equals(expression, that.expression)
      82           1 :         && Objects.equals(passingAtoms, that.passingAtoms)
      83           1 :         && Objects.equals(failingAtoms, that.failingAtoms)
      84           1 :         && Objects.equals(errorMessage, that.errorMessage);
      85             :   }
      86             : 
      87             :   @Override
      88             :   public int hashCode() {
      89           0 :     return Objects.hash(expression, fulfilled, passingAtoms, failingAtoms, errorMessage);
      90             :   }
      91             : }

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