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.common.data.testing; 16 : 17 : import static com.google.common.truth.Truth.assertAbout; 18 : 19 : import com.google.common.truth.ComparableSubject; 20 : import com.google.common.truth.FailureMetadata; 21 : import com.google.common.truth.StringSubject; 22 : import com.google.common.truth.Subject; 23 : import com.google.gerrit.entities.AccountGroup; 24 : import com.google.gerrit.entities.GroupReference; 25 : 26 : public class GroupReferenceSubject extends Subject { 27 : 28 : public static GroupReferenceSubject assertThat(GroupReference group) { 29 0 : return assertAbout(groupReferences()).that(group); 30 : } 31 : 32 : public static Subject.Factory<GroupReferenceSubject, GroupReference> groupReferences() { 33 1 : return GroupReferenceSubject::new; 34 : } 35 : 36 : private final GroupReference group; 37 : 38 : private GroupReferenceSubject(FailureMetadata metadata, GroupReference group) { 39 1 : super(metadata, group); 40 1 : this.group = group; 41 1 : } 42 : 43 : public ComparableSubject<AccountGroup.UUID> groupUuid() { 44 1 : isNotNull(); 45 1 : return check("getUUID()").that(group.getUUID()); 46 : } 47 : 48 : public StringSubject name() { 49 1 : isNotNull(); 50 1 : return check("getName()").that(group.getName()); 51 : } 52 : }