Line data Source code
1 : // Copyright (C) 2018 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 : 19 : import com.google.common.truth.FailureMetadata; 20 : import com.google.common.truth.IntegerSubject; 21 : import com.google.common.truth.IterableSubject; 22 : import com.google.common.truth.StringSubject; 23 : import com.google.common.truth.Subject; 24 : import com.google.gerrit.extensions.common.DiffInfo.FileMeta; 25 : 26 : public class FileMetaSubject extends Subject { 27 : 28 : public static FileMetaSubject assertThat(FileMeta fileMeta) { 29 0 : return assertAbout(fileMetas()).that(fileMeta); 30 : } 31 : 32 : public static Subject.Factory<FileMetaSubject, FileMeta> fileMetas() { 33 4 : return FileMetaSubject::new; 34 : } 35 : 36 : private final FileMeta fileMeta; 37 : 38 : private FileMetaSubject(FailureMetadata failureMetadata, FileMeta fileMeta) { 39 4 : super(failureMetadata, fileMeta); 40 4 : this.fileMeta = fileMeta; 41 4 : } 42 : 43 : public IntegerSubject totalLineCount() { 44 4 : isNotNull(); 45 4 : return check("totalLineCount()").that(fileMeta.lines); 46 : } 47 : 48 : public StringSubject name() { 49 2 : isNotNull(); 50 2 : return check("name").that(fileMeta.name); 51 : } 52 : 53 : public StringSubject commitId() { 54 2 : isNotNull(); 55 2 : return check("commitId").that(fileMeta.commitId); 56 : } 57 : 58 : public StringSubject contentType() { 59 2 : isNotNull(); 60 2 : return check("contentType").that(fileMeta.contentType); 61 : } 62 : 63 : public IterableSubject webLinks() { 64 2 : isNotNull(); 65 2 : return check("webLinks").that(fileMeta.webLinks); 66 : } 67 : }