LCOV - code coverage report
Current view: top level - extensions/common/testing - CommentInfoSubject.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 23 23 100.0 %
Date: 2022-11-19 15:00:39 Functions: 20 20 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2020 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.AccountInfoSubject.accounts;
      19             : import static com.google.gerrit.extensions.common.testing.RangeSubject.ranges;
      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.IntegerSubject;
      25             : import com.google.common.truth.StringSubject;
      26             : import com.google.common.truth.Subject;
      27             : import com.google.gerrit.extensions.client.Side;
      28             : import com.google.gerrit.extensions.common.CommentInfo;
      29             : import com.google.gerrit.truth.ListSubject;
      30             : import java.sql.Timestamp;
      31             : import java.util.List;
      32             : 
      33             : public class CommentInfoSubject extends Subject {
      34             : 
      35             :   public static ListSubject<CommentInfoSubject, CommentInfo> assertThatList(
      36             :       List<CommentInfo> commentInfos) {
      37           2 :     return ListSubject.assertThat(commentInfos, comments());
      38             :   }
      39             : 
      40             :   public static CommentInfoSubject assertThat(CommentInfo commentInfo) {
      41           2 :     return assertAbout(comments()).that(commentInfo);
      42             :   }
      43             : 
      44             :   private static Factory<CommentInfoSubject, CommentInfo> comments() {
      45           2 :     return CommentInfoSubject::new;
      46             :   }
      47             : 
      48             :   private final CommentInfo commentInfo;
      49             : 
      50             :   private CommentInfoSubject(FailureMetadata failureMetadata, CommentInfo commentInfo) {
      51           2 :     super(failureMetadata, commentInfo);
      52           2 :     this.commentInfo = commentInfo;
      53           2 :   }
      54             : 
      55             :   public StringSubject uuid() {
      56           2 :     return check("id").that(commentInfo().id);
      57             :   }
      58             : 
      59             :   public IntegerSubject patchSet() {
      60           2 :     return check("patchSet").that(commentInfo().patchSet);
      61             :   }
      62             : 
      63             :   public StringSubject path() {
      64           2 :     return check("path").that(commentInfo().path);
      65             :   }
      66             : 
      67             :   public IntegerSubject line() {
      68           2 :     return check("line").that(commentInfo().line);
      69             :   }
      70             : 
      71             :   public RangeSubject range() {
      72           2 :     return check("range").about(ranges()).that(commentInfo().range);
      73             :   }
      74             : 
      75             :   public StringSubject message() {
      76           2 :     return check("message").that(commentInfo().message);
      77             :   }
      78             : 
      79             :   public ComparableSubject<Side> side() {
      80           2 :     return check("side").that(commentInfo().side);
      81             :   }
      82             : 
      83             :   public IntegerSubject parent() {
      84           2 :     return check("parent").that(commentInfo().parent);
      85             :   }
      86             : 
      87             :   public BooleanSubject unresolved() {
      88           1 :     return check("unresolved").that(commentInfo().unresolved);
      89             :   }
      90             : 
      91             :   public StringSubject inReplyTo() {
      92           2 :     return check("inReplyTo").that(commentInfo().inReplyTo);
      93             :   }
      94             : 
      95             :   public StringSubject commitId() {
      96           1 :     return check("commitId").that(commentInfo().commitId);
      97             :   }
      98             : 
      99             :   public AccountInfoSubject author() {
     100           2 :     return check("author").about(accounts()).that(commentInfo().author);
     101             :   }
     102             : 
     103             :   public StringSubject tag() {
     104           2 :     return check("tag").that(commentInfo().tag);
     105             :   }
     106             : 
     107             :   public ComparableSubject<Timestamp> updated() {
     108           2 :     return check("updated").that(commentInfo().updated);
     109             :   }
     110             : 
     111             :   public StringSubject changeMessageId() {
     112           1 :     return check("changeMessageId").that(commentInfo().changeMessageId);
     113             :   }
     114             : 
     115             :   private CommentInfo commentInfo() {
     116           2 :     isNotNull();
     117           2 :     return commentInfo;
     118             :   }
     119             : }

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