LCOV - code coverage report
Current view: top level - extensions/common/testing - FixSuggestionInfoSubject.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 12 13 92.3 %
Date: 2022-11-19 15:00:39 Functions: 6 7 85.7 %

          Line data    Source code
       1             : // Copyright (C) 2016 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.testing;
      16             : 
      17             : import static com.google.common.truth.Truth.assertAbout;
      18             : import static com.google.gerrit.extensions.common.testing.FixReplacementInfoSubject.fixReplacements;
      19             : import static com.google.gerrit.truth.ListSubject.elements;
      20             : 
      21             : import com.google.common.truth.FailureMetadata;
      22             : import com.google.common.truth.StringSubject;
      23             : import com.google.common.truth.Subject;
      24             : import com.google.gerrit.extensions.common.FixReplacementInfo;
      25             : import com.google.gerrit.extensions.common.FixSuggestionInfo;
      26             : import com.google.gerrit.truth.ListSubject;
      27             : 
      28             : public class FixSuggestionInfoSubject extends Subject {
      29             : 
      30             :   public static FixSuggestionInfoSubject assertThat(FixSuggestionInfo fixSuggestionInfo) {
      31           0 :     return assertAbout(fixSuggestions()).that(fixSuggestionInfo);
      32             :   }
      33             : 
      34             :   public static Subject.Factory<FixSuggestionInfoSubject, FixSuggestionInfo> fixSuggestions() {
      35           1 :     return FixSuggestionInfoSubject::new;
      36             :   }
      37             : 
      38             :   private final FixSuggestionInfo fixSuggestionInfo;
      39             : 
      40             :   private FixSuggestionInfoSubject(
      41             :       FailureMetadata failureMetadata, FixSuggestionInfo fixSuggestionInfo) {
      42           1 :     super(failureMetadata, fixSuggestionInfo);
      43           1 :     this.fixSuggestionInfo = fixSuggestionInfo;
      44           1 :   }
      45             : 
      46             :   public StringSubject fixId() {
      47           1 :     return check("fixId").that(fixSuggestionInfo.fixId);
      48             :   }
      49             : 
      50             :   public ListSubject<FixReplacementInfoSubject, FixReplacementInfo> replacements() {
      51           1 :     isNotNull();
      52           1 :     return check("replacements")
      53           1 :         .about(elements())
      54           1 :         .thatCustom(fixSuggestionInfo.replacements, fixReplacements());
      55             :   }
      56             : 
      57             :   public FixReplacementInfoSubject onlyReplacement() {
      58           1 :     return replacements().onlyElement();
      59             :   }
      60             : 
      61             :   public StringSubject description() {
      62           1 :     isNotNull();
      63           1 :     return check("description").that(fixSuggestionInfo.description);
      64             :   }
      65             : }

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