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

          Line data    Source code
       1             : // Copyright (C) 2014 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.git.validators;
      16             : 
      17             : import static java.util.stream.Collectors.joining;
      18             : 
      19             : import com.google.common.collect.ImmutableList;
      20             : import com.google.gerrit.server.validators.ValidationException;
      21             : 
      22             : /**
      23             :  * Exception to be thrown when the validation of a ref operation fails and should be aborted.
      24             :  * Examples of a ref operations include creating or updating refs.
      25             :  */
      26             : public class RefOperationValidationException extends ValidationException {
      27             :   private static final long serialVersionUID = 1L;
      28             :   private final ImmutableList<ValidationMessage> messages;
      29             : 
      30             :   public RefOperationValidationException(String reason, ImmutableList<ValidationMessage> messages) {
      31           6 :     super(reason);
      32           6 :     this.messages = messages;
      33           6 :   }
      34             : 
      35             :   public ImmutableList<ValidationMessage> getMessages() {
      36           5 :     return messages;
      37             :   }
      38             : 
      39             :   @Override
      40             :   public String getMessage() {
      41           6 :     return messages.stream()
      42           6 :         .map(ValidationMessage::getMessage)
      43           6 :         .collect(joining("\n", super.getMessage() + "\n", ""));
      44             :   }
      45             : }

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