Merge "Add tests for getting emails"

This commit is contained in:
Patrick Hiesel
2017-12-04 10:37:21 +00:00
committed by Gerrit Code Review

View File

@@ -602,6 +602,42 @@ public class AccountIT extends AbstractDaemonTest {
accountIndexedCounter.assertNoReindex();
}
@Test
public void getOwnEmails() throws Exception {
String email = "preferred@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
setApiUser(foo);
assertThat(getEmails()).containsExactly(email);
setApiUser(admin);
String secondaryEmail = "secondary@example.com";
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id.hashCode()).addEmail(input);
setApiUser(foo);
assertThat(getEmails()).containsExactly(email, secondaryEmail);
}
@Test
public void getEmailsOfOtherAccount() throws Exception {
String email = "preferred2@example.com";
String secondaryEmail = "secondary2@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id.hashCode()).addEmail(input);
setApiUser(user);
assertThat(
gApi.accounts()
.id(foo.id.get())
.getEmails()
.stream()
.map(e -> e.email)
.collect(toSet()))
.containsExactly(email, secondaryEmail);
}
@Test
public void addEmail() throws Exception {
List<String> emails = ImmutableList.of("new.email@example.com", "new.email@example.systems");