TestAccount: Add method to get secondary emails
The secondary emails of an account are all emails except the preferred email. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I26844e8a74667e6713bed36a6f93a92d2e367774
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.testsuite.account;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -33,6 +34,14 @@ public abstract class TestAccount {
|
||||
|
||||
public abstract ImmutableSet<String> emails();
|
||||
|
||||
public ImmutableSet<String> secondaryEmails() {
|
||||
if (!preferredEmail().isPresent()) {
|
||||
return emails();
|
||||
}
|
||||
|
||||
return ImmutableSet.copyOf(Sets.difference(emails(), ImmutableSet.of(preferredEmail().get())));
|
||||
}
|
||||
|
||||
static Builder builder() {
|
||||
return new AutoValue_TestAccount.Builder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user