Fill the display name when loading the account
This was forgotten in change 252771 Change-Id: Ida737b1f304dc77d62867e6abda1b046e0429cbd
This commit is contained in:
		@@ -407,14 +407,14 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
    public TestAccount testAccount(String name) throws Exception {
 | 
			
		||||
      String username = name(name);
 | 
			
		||||
      TestAccount account = accountCreator.create(username, email(username), name);
 | 
			
		||||
      TestAccount account = accountCreator.create(username, email(username), name, null);
 | 
			
		||||
      accountsByEmail.put(account.email(), account);
 | 
			
		||||
      return account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public TestAccount testAccount(String name, String groupName) throws Exception {
 | 
			
		||||
      String username = name(name);
 | 
			
		||||
      TestAccount account = accountCreator.create(username, email(username), name, groupName);
 | 
			
		||||
      TestAccount account = accountCreator.create(username, email(username), name, null, groupName);
 | 
			
		||||
      accountsByEmail.put(account.email(), account);
 | 
			
		||||
      return account;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,7 @@ public class AccountCreator {
 | 
			
		||||
      @Nullable String username,
 | 
			
		||||
      @Nullable String email,
 | 
			
		||||
      @Nullable String fullName,
 | 
			
		||||
      @Nullable String displayName,
 | 
			
		||||
      String... groupNames)
 | 
			
		||||
      throws Exception {
 | 
			
		||||
 | 
			
		||||
@@ -94,7 +95,11 @@ public class AccountCreator {
 | 
			
		||||
        .insert(
 | 
			
		||||
            "Create Test Account",
 | 
			
		||||
            id,
 | 
			
		||||
            u -> u.setFullName(fullName).setPreferredEmail(email).addExternalIds(extIds));
 | 
			
		||||
            u ->
 | 
			
		||||
                u.setFullName(fullName)
 | 
			
		||||
                    .setDisplayName(displayName)
 | 
			
		||||
                    .setPreferredEmail(email)
 | 
			
		||||
                    .addExternalIds(extIds));
 | 
			
		||||
 | 
			
		||||
    if (groupNames != null) {
 | 
			
		||||
      for (String n : groupNames) {
 | 
			
		||||
@@ -107,7 +112,7 @@ public class AccountCreator {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    account = TestAccount.create(id, username, email, fullName, httpPass);
 | 
			
		||||
    account = TestAccount.create(id, username, email, fullName, displayName, httpPass);
 | 
			
		||||
    if (username != null) {
 | 
			
		||||
      accounts.put(username, account);
 | 
			
		||||
    }
 | 
			
		||||
@@ -115,7 +120,7 @@ public class AccountCreator {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount create(@Nullable String username, String group) throws Exception {
 | 
			
		||||
    return create(username, null, username, group);
 | 
			
		||||
    return create(username, null, username, null, group);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount create() throws Exception {
 | 
			
		||||
@@ -123,23 +128,23 @@ public class AccountCreator {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount create(@Nullable String username) throws Exception {
 | 
			
		||||
    return create(username, null, username, (String[]) null);
 | 
			
		||||
    return create(username, null, username, null, (String[]) null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount admin() throws Exception {
 | 
			
		||||
    return create("admin", "admin@example.com", "Administrator", "Administrators");
 | 
			
		||||
    return create("admin", "admin@example.com", "Administrator", "Adminny", "Administrators");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount admin2() throws Exception {
 | 
			
		||||
    return create("admin2", "admin2@example.com", "Administrator2", "Administrators");
 | 
			
		||||
    return create("admin2", "admin2@example.com", "Administrator2", null, "Administrators");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount user() throws Exception {
 | 
			
		||||
    return create("user", "user@example.com", "User");
 | 
			
		||||
    return create("user", "user@example.com", "User", null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount user2() throws Exception {
 | 
			
		||||
    return create("user2", "user2@example.com", "User2");
 | 
			
		||||
    return create("user2", "user2@example.com", "User2", null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public TestAccount get(String username) {
 | 
			
		||||
 
 | 
			
		||||
@@ -47,8 +47,9 @@ public abstract class TestAccount {
 | 
			
		||||
      @Nullable String username,
 | 
			
		||||
      @Nullable String email,
 | 
			
		||||
      @Nullable String fullName,
 | 
			
		||||
      @Nullable String displayName,
 | 
			
		||||
      @Nullable String httpPassword) {
 | 
			
		||||
    return new AutoValue_TestAccount(id, username, email, fullName, httpPassword);
 | 
			
		||||
    return new AutoValue_TestAccount(id, username, email, fullName, displayName, httpPassword);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public abstract Account.Id id();
 | 
			
		||||
@@ -62,6 +63,9 @@ public abstract class TestAccount {
 | 
			
		||||
  @Nullable
 | 
			
		||||
  public abstract String fullName();
 | 
			
		||||
 | 
			
		||||
  @Nullable
 | 
			
		||||
  public abstract String displayName();
 | 
			
		||||
 | 
			
		||||
  @Nullable
 | 
			
		||||
  public abstract String httpPassword();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ import java.util.Set;
 | 
			
		||||
public abstract class AccountDirectory {
 | 
			
		||||
  /** Fields to be populated for a REST API response. */
 | 
			
		||||
  public enum FillOptions {
 | 
			
		||||
    /** Human friendly display name presented in the web interface. */
 | 
			
		||||
    /** Full name or username. */
 | 
			
		||||
    NAME,
 | 
			
		||||
 | 
			
		||||
    /** Preferred email address to contact the user at. */
 | 
			
		||||
@@ -48,7 +48,10 @@ public abstract class AccountDirectory {
 | 
			
		||||
    STATUS,
 | 
			
		||||
 | 
			
		||||
    /** The state of the account (e.g. active or inactive) */
 | 
			
		||||
    STATE
 | 
			
		||||
    STATE,
 | 
			
		||||
 | 
			
		||||
    /** Human friendly display name presented in the web interface chosen by the user. */
 | 
			
		||||
    DISPLAY_NAME
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public abstract void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options)
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,7 @@ public class AccountLoader {
 | 
			
		||||
              FillOptions.NAME,
 | 
			
		||||
              FillOptions.EMAIL,
 | 
			
		||||
              FillOptions.USERNAME,
 | 
			
		||||
              FillOptions.DISPLAY_NAME,
 | 
			
		||||
              FillOptions.STATUS,
 | 
			
		||||
              FillOptions.STATE,
 | 
			
		||||
              FillOptions.AVATARS));
 | 
			
		||||
 
 | 
			
		||||
@@ -143,6 +143,10 @@ public class InternalAccountDirectory extends AccountDirectory {
 | 
			
		||||
      info.username = accountState.userName().orElse(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (options.contains(FillOptions.DISPLAY_NAME)) {
 | 
			
		||||
      info.displayName = account.displayName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (options.contains(FillOptions.STATUS)) {
 | 
			
		||||
      info.status = account.status();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -913,7 +913,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    String email = "preferred@example.com";
 | 
			
		||||
    String name = "Foo";
 | 
			
		||||
    String username = name("foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(username, email, name);
 | 
			
		||||
    TestAccount foo = accountCreator.create(username, email, name, null);
 | 
			
		||||
    String secondaryEmail = "secondary@example.com";
 | 
			
		||||
    EmailInput input = newEmailInput(secondaryEmail);
 | 
			
		||||
    gApi.accounts().id(foo.id().get()).addEmail(input);
 | 
			
		||||
@@ -938,7 +938,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
  public void detailOfOtherAccountDoesntIncludeSecondaryEmailsWithoutModifyAccount()
 | 
			
		||||
      throws Exception {
 | 
			
		||||
    String email = "preferred@example.com";
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
 | 
			
		||||
    String secondaryEmail = "secondary@example.com";
 | 
			
		||||
    EmailInput input = newEmailInput(secondaryEmail);
 | 
			
		||||
    gApi.accounts().id(foo.id().get()).addEmail(input);
 | 
			
		||||
@@ -951,7 +951,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void detailOfOtherAccountIncludeSecondaryEmailsWithModifyAccount() throws Exception {
 | 
			
		||||
    String email = "preferred@example.com";
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
 | 
			
		||||
    String secondaryEmail = "secondary@example.com";
 | 
			
		||||
    EmailInput input = newEmailInput(secondaryEmail);
 | 
			
		||||
    gApi.accounts().id(foo.id().get()).addEmail(input);
 | 
			
		||||
@@ -963,7 +963,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void getOwnEmails() throws Exception {
 | 
			
		||||
    String email = "preferred@example.com";
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
 | 
			
		||||
 | 
			
		||||
    requestScopeOperations.setApiUser(foo.id());
 | 
			
		||||
    assertThat(getEmails()).containsExactly(email);
 | 
			
		||||
@@ -980,7 +980,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void cannotGetEmailsOfOtherAccountWithoutModifyAccount() throws Exception {
 | 
			
		||||
    String email = "preferred2@example.com";
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
 | 
			
		||||
 | 
			
		||||
    requestScopeOperations.setApiUser(user.id());
 | 
			
		||||
    AuthException thrown =
 | 
			
		||||
@@ -992,7 +992,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
  public void getEmailsOfOtherAccount() throws Exception {
 | 
			
		||||
    String email = "preferred3@example.com";
 | 
			
		||||
    String secondaryEmail = "secondary3@example.com";
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
 | 
			
		||||
    EmailInput input = newEmailInput(secondaryEmail);
 | 
			
		||||
    gApi.accounts().id(foo.id().get()).addEmail(input);
 | 
			
		||||
 | 
			
		||||
@@ -1908,7 +1908,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    // Create an account with a preferred email.
 | 
			
		||||
    String username = name("foo");
 | 
			
		||||
    String email = username + "@example.com";
 | 
			
		||||
    TestAccount account = accountCreator.create(username, email, "Foo Bar");
 | 
			
		||||
    TestAccount account = accountCreator.create(username, email, "Foo Bar", null);
 | 
			
		||||
 | 
			
		||||
    ConsistencyCheckInput input = new ConsistencyCheckInput();
 | 
			
		||||
    input.checkAccounts = new CheckAccountsInput();
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ public class GeneralPreferencesIT extends AbstractDaemonTest {
 | 
			
		||||
  @Before
 | 
			
		||||
  public void setUp() throws Exception {
 | 
			
		||||
    String name = name("user42");
 | 
			
		||||
    user42 = accountCreator.create(name, name + "@example.com", "User 42");
 | 
			
		||||
    user42 = accountCreator.create(name, name + "@example.com", "User 42", null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ public class CheckAccessIT extends AbstractDaemonTest {
 | 
			
		||||
    AccountGroup.UUID privilegedGroupUuid =
 | 
			
		||||
        groupOperations.newGroup().name(name("privilegedGroup")).create();
 | 
			
		||||
 | 
			
		||||
    privilegedUser = accountCreator.create("privilegedUser", "snowden@nsa.gov", "Ed Snowden");
 | 
			
		||||
    privilegedUser = accountCreator.create("privilegedUser", "snowden@nsa.gov", "Ed Snowden", null);
 | 
			
		||||
    groupOperations.group(privilegedGroupUuid).forUpdate().addMember(privilegedUser.id()).update();
 | 
			
		||||
 | 
			
		||||
    projectOperations
 | 
			
		||||
 
 | 
			
		||||
@@ -516,7 +516,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void pushForMasterWithNotify() throws Exception {
 | 
			
		||||
    // create a user that watches the project
 | 
			
		||||
    TestAccount user3 = accountCreator.create("user3", "user3@example.com", "User3");
 | 
			
		||||
    TestAccount user3 = accountCreator.create("user3", "user3@example.com", "User3", null);
 | 
			
		||||
    List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
 | 
			
		||||
    ProjectWatchInfo pwi = new ProjectWatchInfo();
 | 
			
		||||
    pwi.project = project.get();
 | 
			
		||||
@@ -676,7 +676,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
    // add several reviewers
 | 
			
		||||
    TestAccount user2 =
 | 
			
		||||
        accountCreator.create("another-user", "another.user@example.com", "Another User");
 | 
			
		||||
        accountCreator.create("another-user", "another.user@example.com", "Another User", null);
 | 
			
		||||
    r =
 | 
			
		||||
        pushTo(
 | 
			
		||||
            "refs/for/master%topic="
 | 
			
		||||
 
 | 
			
		||||
@@ -182,7 +182,8 @@ public class PushAccountIT extends AbstractDaemonTest {
 | 
			
		||||
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
 | 
			
		||||
    try (Registration registration =
 | 
			
		||||
        extensionRegistry.newRegistration().add(accountIndexedCounter)) {
 | 
			
		||||
      TestAccount foo = accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo");
 | 
			
		||||
      TestAccount foo =
 | 
			
		||||
          accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo", null);
 | 
			
		||||
      String userRef = RefNames.refsUsers(foo.id());
 | 
			
		||||
      accountIndexedCounter.clear();
 | 
			
		||||
 | 
			
		||||
@@ -442,7 +443,7 @@ public class PushAccountIT extends AbstractDaemonTest {
 | 
			
		||||
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
 | 
			
		||||
    try (Registration registration =
 | 
			
		||||
        extensionRegistry.newRegistration().add(accountIndexedCounter)) {
 | 
			
		||||
      TestAccount oooUser = accountCreator.create("away", "away@mail.invalid", "Ambrose Way");
 | 
			
		||||
      TestAccount oooUser = accountCreator.create("away", "away@mail.invalid", "Ambrose Way", null);
 | 
			
		||||
      requestScopeOperations.setApiUser(oooUser.id());
 | 
			
		||||
 | 
			
		||||
      // Must clone as oooUser to ensure the push is allowed.
 | 
			
		||||
@@ -539,7 +540,8 @@ public class PushAccountIT extends AbstractDaemonTest {
 | 
			
		||||
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
 | 
			
		||||
    try (Registration registration =
 | 
			
		||||
        extensionRegistry.newRegistration().add(accountIndexedCounter)) {
 | 
			
		||||
      TestAccount foo = accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo");
 | 
			
		||||
      TestAccount foo =
 | 
			
		||||
          accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo", null);
 | 
			
		||||
      String userRef = RefNames.refsUsers(foo.id());
 | 
			
		||||
 | 
			
		||||
      String noEmail = "no.email";
 | 
			
		||||
@@ -584,7 +586,8 @@ public class PushAccountIT extends AbstractDaemonTest {
 | 
			
		||||
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
 | 
			
		||||
    try (Registration registration =
 | 
			
		||||
        extensionRegistry.newRegistration().add(accountIndexedCounter)) {
 | 
			
		||||
      TestAccount foo = accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo");
 | 
			
		||||
      TestAccount foo =
 | 
			
		||||
          accountCreator.create(name("foo"), name("foo") + "@example.com", "Foo", null);
 | 
			
		||||
      String userRef = RefNames.refsUsers(foo.id());
 | 
			
		||||
      accountIndexedCounter.clear();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@ public class AccountAssert {
 | 
			
		||||
  public static void assertAccountInfo(TestAccount testAccount, AccountInfo accountInfo) {
 | 
			
		||||
    assertThat(accountInfo._accountId).isEqualTo(testAccount.id().get());
 | 
			
		||||
    assertThat(accountInfo.name).isEqualTo(testAccount.fullName());
 | 
			
		||||
    assertThat(accountInfo.displayName).isEqualTo(testAccount.displayName());
 | 
			
		||||
    assertThat(accountInfo.email).isEqualTo(testAccount.email());
 | 
			
		||||
    assertThat(accountInfo.inactive).isNull();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -194,7 +194,8 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
    // CC a group that overlaps with some existing reviewers and CCed accounts.
 | 
			
		||||
    TestAccount reviewer =
 | 
			
		||||
        accountCreator.create(name("reviewer"), "addCcGroup-reviewer@example.com", "Reviewer");
 | 
			
		||||
        accountCreator.create(
 | 
			
		||||
            name("reviewer"), "addCcGroup-reviewer@example.com", "Reviewer", null);
 | 
			
		||||
    result = addReviewer(changeId, reviewer.username());
 | 
			
		||||
    assertThat(result.error).isNull();
 | 
			
		||||
    sender.clear();
 | 
			
		||||
@@ -546,11 +547,11 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
 | 
			
		||||
  public void addOverlappingGroups() throws Exception {
 | 
			
		||||
    String emailPrefix = "addOverlappingGroups-";
 | 
			
		||||
    TestAccount user1 =
 | 
			
		||||
        accountCreator.create(name("user1"), emailPrefix + "user1@example.com", "User1");
 | 
			
		||||
        accountCreator.create(name("user1"), emailPrefix + "user1@example.com", "User1", null);
 | 
			
		||||
    TestAccount user2 =
 | 
			
		||||
        accountCreator.create(name("user2"), emailPrefix + "user2@example.com", "User2");
 | 
			
		||||
        accountCreator.create(name("user2"), emailPrefix + "user2@example.com", "User2", null);
 | 
			
		||||
    TestAccount user3 =
 | 
			
		||||
        accountCreator.create(name("user3"), emailPrefix + "user3@example.com", "User3");
 | 
			
		||||
        accountCreator.create(name("user3"), emailPrefix + "user3@example.com", "User3", null);
 | 
			
		||||
    String group1 = groupOperations.newGroup().name("group1").create().get();
 | 
			
		||||
    String group2 = groupOperations.newGroup().name("group2").create().get();
 | 
			
		||||
    gApi.groups().id(group1).addMembers(user1.username(), user2.username());
 | 
			
		||||
@@ -912,7 +913,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
 | 
			
		||||
    for (int i = 0; i < n; i++) {
 | 
			
		||||
      result.add(
 | 
			
		||||
          accountCreator.create(
 | 
			
		||||
              name("u" + i), emailPrefix + "-" + i + "@example.com", "Full Name " + i));
 | 
			
		||||
              name("u" + i), emailPrefix + "-" + i + "@example.com", "Full Name " + i, null));
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -570,7 +570,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
  private TestAccount createAccountWithSecondaryEmail(String name, String secondaryEmail)
 | 
			
		||||
      throws Exception {
 | 
			
		||||
    TestAccount foo = accountCreator.create(name(name), "foo.primary@example.com", "Foo");
 | 
			
		||||
    TestAccount foo = accountCreator.create(name(name), "foo.primary@example.com", "Foo", null);
 | 
			
		||||
    EmailInput input = new EmailInput();
 | 
			
		||||
    input.email = secondaryEmail;
 | 
			
		||||
    input.noConfirmation = true;
 | 
			
		||||
@@ -601,7 +601,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private TestAccount user(String name, String fullName, String emailName) throws Exception {
 | 
			
		||||
    return accountCreator.create(name(name), name(emailName) + "@example.com", fullName);
 | 
			
		||||
    return accountCreator.create(name(name), name(emailName) + "@example.com", fullName, null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private TestAccount user(String name, String fullName) throws Exception {
 | 
			
		||||
 
 | 
			
		||||
@@ -76,9 +76,9 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Before
 | 
			
		||||
  public void createExtraAccounts() throws Exception {
 | 
			
		||||
    extraReviewer =
 | 
			
		||||
        accountCreator.create("extraReviewer", "extraReviewer@example.com", "extraReviewer");
 | 
			
		||||
    extraCcer = accountCreator.create("extraCcer", "extraCcer@example.com", "extraCcer");
 | 
			
		||||
    other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
        accountCreator.create("extraReviewer", "extraReviewer@example.com", "extraReviewer", null);
 | 
			
		||||
    extraCcer = accountCreator.create("extraCcer", "extraCcer@example.com", "extraCcer", null);
 | 
			
		||||
    other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Before
 | 
			
		||||
@@ -129,7 +129,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void abandonReviewableChangeByOther() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    abandon(sc.changeId, other);
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
        .sent("abandon", sc)
 | 
			
		||||
@@ -145,7 +145,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void abandonReviewableChangeByOtherCcingSelf() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    abandon(sc.changeId, other, CC_ON_OWN_COMMENTS);
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
        .sent("abandon", sc)
 | 
			
		||||
@@ -190,7 +190,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void abandonReviewableChangeByOtherCcingSelfNotifyOwner() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    abandon(sc.changeId, other, CC_ON_OWN_COMMENTS, OWNER);
 | 
			
		||||
    assertThat(sender).sent("abandon", sc).to(sc.owner).cc(other).noOneElse();
 | 
			
		||||
    assertThat(sender).didNotSend();
 | 
			
		||||
@@ -277,7 +277,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToReviewableChange(Adder adder) throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email());
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -301,7 +301,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToReviewableChangeByOwnerCcingSelf(Adder adder) throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email(), CC_ON_OWN_COMMENTS, null);
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -324,9 +324,9 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToReviewableChangeByOther(Adder adder) throws Exception {
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, other, reviewer.email());
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -349,9 +349,9 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToReviewableChangeByOtherCcingSelf(Adder adder) throws Exception {
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, other, reviewer.email(), CC_ON_OWN_COMMENTS, null);
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -399,7 +399,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToWipChange(Adder adder) throws Exception {
 | 
			
		||||
    StagedChange sc = stageWipChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email());
 | 
			
		||||
    assertThat(sender).didNotSend();
 | 
			
		||||
  }
 | 
			
		||||
@@ -417,7 +417,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void addReviewerToReviewableWipChangeSingly() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableWipChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(singly(), sc.changeId, sc.owner, reviewer.email());
 | 
			
		||||
    // TODO(dborowitz): In theory this should match the batch case, but we don't currently pass
 | 
			
		||||
    // enough info into AddReviewersEmail#emailReviewers to distinguish the reviewStarted case.
 | 
			
		||||
@@ -429,7 +429,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void addReviewerToReviewableWipChangeBatch() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableWipChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(batch(), sc.changeId, sc.owner, reviewer.email());
 | 
			
		||||
    // For a review-started WIP change, same as in the notify=ALL case. It's not especially
 | 
			
		||||
    // important to notify just because a reviewer is added, but we do want to notify in the other
 | 
			
		||||
@@ -444,7 +444,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToWipChangeNotifyAll(Adder adder) throws Exception {
 | 
			
		||||
    StagedChange sc = stageWipChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email(), NotifyHandling.ALL);
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -468,7 +468,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  private void addReviewerToReviewableChangeNotifyOwnerReviewers(Adder adder) throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email(), OWNER_REVIEWERS);
 | 
			
		||||
    // TODO(logan): Should CCs be included?
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -493,7 +493,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  private void addReviewerToReviewableChangeByOwnerCcingSelfNotifyOwner(Adder adder)
 | 
			
		||||
      throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email(), CC_ON_OWN_COMMENTS, OWNER);
 | 
			
		||||
    assertThat(sender).didNotSend();
 | 
			
		||||
  }
 | 
			
		||||
@@ -511,7 +511,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  private void addReviewerToReviewableChangeByOwnerCcingSelfNotifyNone(Adder adder)
 | 
			
		||||
      throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added");
 | 
			
		||||
    TestAccount reviewer = accountCreator.create("added", "added@example.com", "added", null);
 | 
			
		||||
    addReviewer(adder, sc.changeId, sc.owner, reviewer.email(), CC_ON_OWN_COMMENTS, NONE);
 | 
			
		||||
    assertThat(sender).didNotSend();
 | 
			
		||||
  }
 | 
			
		||||
@@ -695,7 +695,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void commentOnReviewableChangeByOther() throws Exception {
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    review(other, sc.changeId, ENABLED);
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -711,7 +711,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void commentOnReviewableChangeByOtherCcingSelf() throws Exception {
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    review(other, sc.changeId, CC_ON_OWN_COMMENTS);
 | 
			
		||||
    assertThat(sender)
 | 
			
		||||
@@ -2353,7 +2353,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void changeAssigneeOnReviewableChange() throws Exception {
 | 
			
		||||
    StagedChange sc = stageReviewableChange();
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other");
 | 
			
		||||
    TestAccount other = accountCreator.create("other", "other@example.com", "other", null);
 | 
			
		||||
    assign(sc, sc.owner, other);
 | 
			
		||||
    sender.clear();
 | 
			
		||||
    assign(sc, sc.owner, sc.assignee);
 | 
			
		||||
 
 | 
			
		||||
@@ -279,7 +279,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
 | 
			
		||||
    sender.clear();
 | 
			
		||||
 | 
			
		||||
    // watch project as user2
 | 
			
		||||
    TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2");
 | 
			
		||||
    TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2", null);
 | 
			
		||||
    requestScopeOperations.setApiUser(user2.id());
 | 
			
		||||
    watch(watchedProject);
 | 
			
		||||
 | 
			
		||||
@@ -391,7 +391,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
 | 
			
		||||
    sender.clear();
 | 
			
		||||
 | 
			
		||||
    // watch project as user2
 | 
			
		||||
    TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2");
 | 
			
		||||
    TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2", null);
 | 
			
		||||
    requestScopeOperations.setApiUser(user2.id());
 | 
			
		||||
    watch(anyProject);
 | 
			
		||||
 | 
			
		||||
@@ -528,7 +528,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
 | 
			
		||||
    // watch project as user that can view all private change
 | 
			
		||||
    TestAccount userThatCanViewPrivateChanges =
 | 
			
		||||
        accountCreator.create(
 | 
			
		||||
            "user2", "user2@test.com", "User2", groupThatCanViewPrivateChanges.name);
 | 
			
		||||
            "user2", "user2@test.com", "User2", null, groupThatCanViewPrivateChanges.name);
 | 
			
		||||
    requestScopeOperations.setApiUser(userThatCanViewPrivateChanges.id());
 | 
			
		||||
    watch(watchedProject);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user