LCOV - code coverage report
Current view: top level - extensions/common/testing - DiffInfoSubject.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 22 24 91.7 %
Date: 2022-11-19 15:00:39 Functions: 10 11 90.9 %

          Line data    Source code
       1             : // Copyright (C) 2017 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.FileMetaSubject.fileMetas;
      19             : import static com.google.gerrit.truth.ListSubject.elements;
      20             : 
      21             : import com.google.common.truth.BooleanSubject;
      22             : import com.google.common.truth.ComparableSubject;
      23             : import com.google.common.truth.FailureMetadata;
      24             : import com.google.common.truth.IterableSubject;
      25             : import com.google.common.truth.Subject;
      26             : import com.google.gerrit.extensions.common.ChangeType;
      27             : import com.google.gerrit.extensions.common.DiffInfo;
      28             : import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
      29             : import com.google.gerrit.extensions.common.DiffInfo.IntraLineStatus;
      30             : import com.google.gerrit.truth.ListSubject;
      31             : 
      32             : public class DiffInfoSubject extends Subject {
      33             : 
      34             :   public static DiffInfoSubject assertThat(DiffInfo diffInfo) {
      35           5 :     return assertAbout(DiffInfoSubject::new).that(diffInfo);
      36             :   }
      37             : 
      38             :   private final DiffInfo diffInfo;
      39             : 
      40             :   private DiffInfoSubject(FailureMetadata failureMetadata, DiffInfo diffInfo) {
      41           5 :     super(failureMetadata, diffInfo);
      42           5 :     this.diffInfo = diffInfo;
      43           5 :   }
      44             : 
      45             :   public ListSubject<ContentEntrySubject, ContentEntry> content() {
      46           4 :     isNotNull();
      47           4 :     return check("content")
      48           4 :         .about(elements())
      49           4 :         .thatCustom(diffInfo.content, ContentEntrySubject.contentEntries());
      50             :   }
      51             : 
      52             :   public ComparableSubject<ChangeType> changeType() {
      53           5 :     isNotNull();
      54           5 :     return check("changeType").that(diffInfo.changeType);
      55             :   }
      56             : 
      57             :   public FileMetaSubject metaA() {
      58           4 :     isNotNull();
      59           4 :     return check("metaA").about(fileMetas()).that(diffInfo.metaA);
      60             :   }
      61             : 
      62             :   public FileMetaSubject metaB() {
      63           4 :     isNotNull();
      64           4 :     return check("metaB").about(fileMetas()).that(diffInfo.metaB);
      65             :   }
      66             : 
      67             :   public ComparableSubject<IntraLineStatus> intralineStatus() {
      68           2 :     isNotNull();
      69           2 :     return check("intralineStatus").that(diffInfo.intralineStatus);
      70             :   }
      71             : 
      72             :   public IterableSubject webLinks() {
      73           4 :     isNotNull();
      74           4 :     return check("webLinks").that(diffInfo.webLinks);
      75             :   }
      76             : 
      77             :   public IterableSubject editWebLinks() {
      78           0 :     isNotNull();
      79           0 :     return check("editWebLinks").that(diffInfo.editWebLinks);
      80             :   }
      81             : 
      82             :   public BooleanSubject binary() {
      83           4 :     isNotNull();
      84           4 :     return check("binary").that(diffInfo.binary);
      85             :   }
      86             : 
      87             :   public IterableSubject diffHeader() {
      88           4 :     isNotNull();
      89           4 :     return check("diffHeader").that(diffInfo.diffHeader);
      90             :   }
      91             : }

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