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 : 19 : import com.google.common.truth.FailureMetadata; 20 : import com.google.common.truth.IntegerSubject; 21 : import com.google.common.truth.Subject; 22 : import com.google.gerrit.extensions.common.AccountInfo; 23 : 24 : /** A Truth subject for {@link AccountInfo} instances. */ 25 : public class AccountInfoSubject extends Subject { 26 : 27 : private final AccountInfo accountInfo; 28 : 29 : public static AccountInfoSubject assertThat(AccountInfo accountInfo) { 30 0 : return assertAbout(accounts()).that(accountInfo); 31 : } 32 : 33 : public static Factory<AccountInfoSubject, AccountInfo> accounts() { 34 2 : return AccountInfoSubject::new; 35 : } 36 : 37 : private AccountInfoSubject(FailureMetadata metadata, AccountInfo accountInfo) { 38 2 : super(metadata, accountInfo); 39 2 : this.accountInfo = accountInfo; 40 2 : } 41 : 42 : public IntegerSubject id() { 43 2 : return check("id").that(accountInfo()._accountId); 44 : } 45 : 46 : private AccountInfo accountInfo() { 47 2 : isNotNull(); 48 2 : return accountInfo; 49 : } 50 : }