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.acceptance.testsuite.account; 16 : 17 : import com.google.auto.value.AutoValue; 18 : import com.google.common.collect.ImmutableSet; 19 : import com.google.common.collect.Sets; 20 : import com.google.gerrit.entities.Account; 21 : import java.util.Optional; 22 : 23 : @AutoValue 24 132 : public abstract class TestAccount { 25 : public abstract Account.Id accountId(); 26 : 27 : public abstract Optional<String> fullname(); 28 : 29 : public abstract Optional<String> preferredEmail(); 30 : 31 : public abstract Optional<String> username(); 32 : 33 : public abstract boolean active(); 34 : 35 : public abstract ImmutableSet<String> emails(); 36 : 37 : public ImmutableSet<String> secondaryEmails() { 38 0 : if (!preferredEmail().isPresent()) { 39 0 : return emails(); 40 : } 41 : 42 0 : return ImmutableSet.copyOf(Sets.difference(emails(), ImmutableSet.of(preferredEmail().get()))); 43 : } 44 : 45 : static Builder builder() { 46 132 : return new AutoValue_TestAccount.Builder(); 47 : } 48 : 49 : @AutoValue.Builder 50 132 : abstract static class Builder { 51 : abstract Builder accountId(Account.Id accountId); 52 : 53 : abstract Builder fullname(Optional<String> fullname); 54 : 55 : abstract Builder preferredEmail(Optional<String> fullname); 56 : 57 : abstract Builder username(Optional<String> username); 58 : 59 : abstract Builder active(boolean active); 60 : 61 : abstract Builder emails(ImmutableSet<String> emails); 62 : 63 : abstract TestAccount build(); 64 : } 65 : }