AccountsUpdate: Return AccountState instead of Account

On insert/update of an account the updated Account instance was
returned. However on insert/update of an account not only account
properties can be set, but also external IDs, watched projectis and
general preferences. To be consistent we should rather return the
updated AccountState which includes external IDs, watched projects and
general preferences in addition to the account.

Change-Id: Iff30984fe39551f88480399b57ce9cb3a90a10e2
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-10 13:28:50 +01:00
parent 06e676fc95
commit d845be694f
8 changed files with 77 additions and 53 deletions

View File

@@ -238,14 +238,14 @@ public class AccountManager {
} }
if (!accountUpdates.isEmpty()) { if (!accountUpdates.isEmpty()) {
Account account = AccountState accountState =
accountsUpdateFactory accountsUpdateFactory
.create() .create()
.update( .update(
"Update Account on Login", "Update Account on Login",
user.getAccountId(), user.getAccountId(),
AccountUpdater.joinConsumers(accountUpdates)); AccountUpdater.joinConsumers(accountUpdates));
if (account == null) { if (accountState == null) {
throw new OrmException("Account " + user.getAccountId() + " has been deleted"); throw new OrmException("Account " + user.getAccountId() + " has been deleted");
} }
} }
@@ -266,9 +266,9 @@ public class AccountManager {
boolean isFirstAccount = awaitsFirstAccountCheck.getAndSet(false) && !accounts.hasAnyAccount(); boolean isFirstAccount = awaitsFirstAccountCheck.getAndSet(false) && !accounts.hasAnyAccount();
Account account; AccountState accountState;
try { try {
account = accountState =
accountsUpdateFactory accountsUpdateFactory
.create() .create()
.insert( .insert(
@@ -318,7 +318,7 @@ public class AccountManager {
addGroupMember(db, adminGroupUuid, user); addGroupMember(db, adminGroupUuid, user);
} }
realm.onCreateAccount(who, account); realm.onCreateAccount(who, accountState.getAccount());
return new AuthResult(newId, extId.key(), true); return new AuthResult(newId, extId.key(), true);
} }

View File

@@ -360,7 +360,7 @@ public class AccountsUpdate {
* @throws OrmException if creating the user branch fails * @throws OrmException if creating the user branch fails
* @throws ConfigInvalidException if any of the account fields has an invalid value * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public Account insert( public AccountState insert(
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init) String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
throws OrmException, IOException, ConfigInvalidException { throws OrmException, IOException, ConfigInvalidException {
return insert(message, accountId, AccountUpdater.fromConsumer(init)); return insert(message, accountId, AccountUpdater.fromConsumer(init));
@@ -378,7 +378,7 @@ public class AccountsUpdate {
* @throws OrmException if creating the user branch fails * @throws OrmException if creating the user branch fails
* @throws ConfigInvalidException if any of the account fields has an invalid value * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public Account insert(String message, Account.Id accountId, AccountUpdater updater) public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
throws OrmException, IOException, ConfigInvalidException { throws OrmException, IOException, ConfigInvalidException {
return updateAccount( return updateAccount(
r -> { r -> {
@@ -399,7 +399,8 @@ public class AccountsUpdate {
accountConfig.setAccountUpdate(update); accountConfig.setAccountUpdate(update);
ExternalIdNotes extIdNotes = ExternalIdNotes extIdNotes =
createExternalIdNotes(r, accountConfig.getExternalIdsRev(), accountId, update); createExternalIdNotes(r, accountConfig.getExternalIdsRev(), accountId, update);
UpdatedAccount updatedAccounts = new UpdatedAccount(message, accountConfig, extIdNotes); UpdatedAccount updatedAccounts =
new UpdatedAccount(allUsersName, externalIds, message, accountConfig, extIdNotes);
updatedAccounts.setCreated(true); updatedAccounts.setCreated(true);
return updatedAccounts; return updatedAccounts;
}); });
@@ -418,7 +419,7 @@ public class AccountsUpdate {
* @throws OrmException if updating the user branch fails * @throws OrmException if updating the user branch fails
* @throws ConfigInvalidException if any of the account fields has an invalid value * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public Account update( public AccountState update(
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update) String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update)
throws OrmException, IOException, ConfigInvalidException { throws OrmException, IOException, ConfigInvalidException {
return update(message, accountId, AccountUpdater.fromConsumer(update)); return update(message, accountId, AccountUpdater.fromConsumer(update));
@@ -438,7 +439,7 @@ public class AccountsUpdate {
* @throws ConfigInvalidException if any of the account fields has an invalid value * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
@Nullable @Nullable
public Account update(String message, Account.Id accountId, AccountUpdater updater) public AccountState update(String message, Account.Id accountId, AccountUpdater updater)
throws OrmException, IOException, ConfigInvalidException { throws OrmException, IOException, ConfigInvalidException {
return updateAccount( return updateAccount(
r -> { r -> {
@@ -456,7 +457,8 @@ public class AccountsUpdate {
accountConfig.setAccountUpdate(update); accountConfig.setAccountUpdate(update);
ExternalIdNotes extIdNotes = ExternalIdNotes extIdNotes =
createExternalIdNotes(r, accountConfig.getExternalIdsRev(), accountId, update); createExternalIdNotes(r, accountConfig.getExternalIdsRev(), accountId, update);
UpdatedAccount updatedAccounts = new UpdatedAccount(message, accountConfig, extIdNotes); UpdatedAccount updatedAccounts =
new UpdatedAccount(allUsersName, externalIds, message, accountConfig, extIdNotes);
return updatedAccounts; return updatedAccounts;
}); });
} }
@@ -468,7 +470,7 @@ public class AccountsUpdate {
return accountConfig; return accountConfig;
} }
private Account updateAccount(AccountUpdate accountUpdate) private AccountState updateAccount(AccountUpdate accountUpdate)
throws IOException, ConfigInvalidException, OrmException { throws IOException, ConfigInvalidException, OrmException {
return retryHelper.execute( return retryHelper.execute(
ActionType.ACCOUNT_UPDATE, ActionType.ACCOUNT_UPDATE,
@@ -508,6 +510,7 @@ public class AccountsUpdate {
beforeCommit.run(); beforeCommit.run();
BatchRefUpdate batchRefUpdate = allUsersRepo.getRefDatabase().newBatchUpdate(); BatchRefUpdate batchRefUpdate = allUsersRepo.getRefDatabase().newBatchUpdate();
if (updatedAccount.isCreated()) { if (updatedAccount.isCreated()) {
commitNewAccountConfig( commitNewAccountConfig(
updatedAccount.getMessage(), updatedAccount.getMessage(),
@@ -527,6 +530,7 @@ public class AccountsUpdate {
allUsersRepo, allUsersRepo,
batchRefUpdate, batchRefUpdate,
updatedAccount.getExternalIdNotes()); updatedAccount.getExternalIdNotes());
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo); RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
updatedAccount.getExternalIdNotes().updateCaches(); updatedAccount.getExternalIdNotes().updateCaches();
gitRefUpdated.fire( gitRefUpdated.fire(
@@ -599,6 +603,8 @@ public class AccountsUpdate {
} }
private static class UpdatedAccount { private static class UpdatedAccount {
private final AllUsersName allUsersName;
private final ExternalIds externalIds;
private final String message; private final String message;
private final AccountConfig accountConfig; private final AccountConfig accountConfig;
private final ExternalIdNotes extIdNotes; private final ExternalIdNotes extIdNotes;
@@ -606,8 +612,14 @@ public class AccountsUpdate {
private boolean created; private boolean created;
private UpdatedAccount( private UpdatedAccount(
String message, AccountConfig accountConfig, ExternalIdNotes extIdNotes) { AllUsersName allUsersName,
ExternalIds externalIds,
String message,
AccountConfig accountConfig,
ExternalIdNotes extIdNotes) {
checkState(!Strings.isNullOrEmpty(message), "message for account update must be set"); checkState(!Strings.isNullOrEmpty(message), "message for account update must be set");
this.allUsersName = checkNotNull(allUsersName);
this.externalIds = checkNotNull(externalIds);
this.message = checkNotNull(message); this.message = checkNotNull(message);
this.accountConfig = checkNotNull(accountConfig); this.accountConfig = checkNotNull(accountConfig);
this.extIdNotes = checkNotNull(extIdNotes); this.extIdNotes = checkNotNull(extIdNotes);
@@ -621,8 +633,16 @@ public class AccountsUpdate {
return accountConfig; return accountConfig;
} }
public Account getAccount() { public AccountState getAccount() throws IOException {
return accountConfig.getLoadedAccount().get(); Account account = accountConfig.getLoadedAccount().get();
return new AccountState(
allUsersName,
account,
extIdNotes.getRevision() != null
? externalIds.byAccount(account.getId(), extIdNotes.getRevision())
: ImmutableSet.of(),
accountConfig.getProjectWatches(),
accountConfig.getGeneralPreferences());
} }
public ExternalIdNotes getExternalIdNotes() { public ExternalIdNotes getExternalIdNotes() {

View File

@@ -39,7 +39,7 @@ public class SetInactiveFlag {
public Response<?> deactivate(Account.Id accountId) public Response<?> deactivate(Account.Id accountId)
throws RestApiException, IOException, ConfigInvalidException, OrmException { throws RestApiException, IOException, ConfigInvalidException, OrmException {
AtomicBoolean alreadyInactive = new AtomicBoolean(false); AtomicBoolean alreadyInactive = new AtomicBoolean(false);
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update( .update(
@@ -52,7 +52,7 @@ public class SetInactiveFlag {
u.setActive(false); u.setActive(false);
} }
}); });
if (account == null) { if (accountState == null) {
throw new ResourceNotFoundException("account not found"); throw new ResourceNotFoundException("account not found");
} }
if (alreadyInactive.get()) { if (alreadyInactive.get()) {
@@ -64,7 +64,7 @@ public class SetInactiveFlag {
public Response<String> activate(Account.Id accountId) public Response<String> activate(Account.Id accountId)
throws ResourceNotFoundException, IOException, ConfigInvalidException, OrmException { throws ResourceNotFoundException, IOException, ConfigInvalidException, OrmException {
AtomicBoolean alreadyActive = new AtomicBoolean(false); AtomicBoolean alreadyActive = new AtomicBoolean(false);
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update( .update(
@@ -77,7 +77,7 @@ public class SetInactiveFlag {
u.setActive(true); u.setActive(true);
} }
}); });
if (account == null) { if (accountState == null) {
throw new ResourceNotFoundException("account not found"); throw new ResourceNotFoundException("account not found");
} }
return alreadyActive.get() ? Response.ok("") : Response.created(""); return alreadyActive.get() ? Response.ok("") : Response.created("");

View File

@@ -92,6 +92,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.Sequences; import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.account.AccountResolver; import com.google.gerrit.server.account.AccountResolver;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.change.ChangeInserter; import com.google.gerrit.server.change.ChangeInserter;
import com.google.gerrit.server.change.SetHashtagsOp; import com.google.gerrit.server.change.SetHashtagsOp;
@@ -2980,7 +2981,7 @@ class ReceiveCommits {
} }
logDebug("Updating full name of caller"); logDebug("Updating full name of caller");
try { try {
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update( .update(
@@ -2991,8 +2992,8 @@ class ReceiveCommits {
u.setFullName(setFullNameTo); u.setFullName(setFullNameTo);
} }
}); });
if (account != null) { if (accountState != null) {
user.getAccount().setFullName(account.getFullName()); user.getAccount().setFullName(accountState.getAccount().getFullName());
} }
} catch (OrmException | IOException | ConfigInvalidException e) { } catch (OrmException | IOException | ConfigInvalidException e) {
logWarn("Failed to update full name of caller", e); logWarn("Failed to update full name of caller", e);

View File

@@ -22,10 +22,10 @@ import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.Realm; import com.google.gerrit.server.account.Realm;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
@@ -79,15 +79,15 @@ public class PutName implements RestModifyView<AccountResource, NameInput> {
} }
String newName = input.name; String newName = input.name;
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update("Set Full Name via API", user.getAccountId(), u -> u.setFullName(newName)); .update("Set Full Name via API", user.getAccountId(), u -> u.setFullName(newName));
if (account == null) { if (accountState == null) {
throw new ResourceNotFoundException("account not found"); throw new ResourceNotFoundException("account not found");
} }
return Strings.isNullOrEmpty(account.getFullName()) return Strings.isNullOrEmpty(accountState.getAccount().getFullName())
? Response.none() ? Response.none()
: Response.ok(account.getFullName()); : Response.ok(accountState.getAccount().getFullName());
} }
} }

View File

@@ -19,10 +19,10 @@ import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
@@ -65,7 +65,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
public Response<String> apply(IdentifiedUser user, String email) public Response<String> apply(IdentifiedUser user, String email)
throws ResourceNotFoundException, IOException, ConfigInvalidException, OrmException { throws ResourceNotFoundException, IOException, ConfigInvalidException, OrmException {
AtomicBoolean alreadyPreferred = new AtomicBoolean(false); AtomicBoolean alreadyPreferred = new AtomicBoolean(false);
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update( .update(
@@ -78,7 +78,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
u.setPreferredEmail(email); u.setPreferredEmail(email);
} }
}); });
if (account == null) { if (accountState == null) {
throw new ResourceNotFoundException("account not found"); throw new ResourceNotFoundException("account not found");
} }
return alreadyPreferred.get() ? Response.ok("") : Response.created(""); return alreadyPreferred.get() ? Response.ok("") : Response.created("");

View File

@@ -20,10 +20,10 @@ import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
@@ -68,15 +68,15 @@ public class PutStatus implements RestModifyView<AccountResource, StatusInput> {
} }
String newStatus = input.status; String newStatus = input.status;
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update("Set Status via API", user.getAccountId(), u -> u.setStatus(newStatus)); .update("Set Status via API", user.getAccountId(), u -> u.setStatus(newStatus));
if (account == null) { if (accountState == null) {
throw new ResourceNotFoundException("account not found"); throw new ResourceNotFoundException("account not found");
} }
return Strings.isNullOrEmpty(account.getStatus()) return Strings.isNullOrEmpty(accountState.getAccount().getStatus())
? Response.none() ? Response.none()
: Response.ok(account.getStatus()); : Response.ok(accountState.getAccount().getStatus());
} }
} }

View File

@@ -373,14 +373,14 @@ public class AccountIT extends AbstractDaemonTest {
Account.Id accountId = new Account.Id(seq.nextAccountId()); Account.Id accountId = new Account.Id(seq.nextAccountId());
String fullName = "Foo"; String fullName = "Foo";
ExternalId extId = ExternalId.createEmail(accountId, "foo@example.com"); ExternalId extId = ExternalId.createEmail(accountId, "foo@example.com");
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.insert( .insert(
"Create Account Atomically", "Create Account Atomically",
accountId, accountId,
u -> u.setFullName(fullName).addExternalId(extId)); u -> u.setFullName(fullName).addExternalId(extId));
assertThat(account.getFullName()).isEqualTo(fullName); assertThat(accountState.getAccount().getFullName()).isEqualTo(fullName);
AccountInfo info = gApi.accounts().id(accountId.get()).get(); AccountInfo info = gApi.accounts().id(accountId.get()).get();
assertThat(info.name).isEqualTo(fullName); assertThat(info.name).isEqualTo(fullName);
@@ -401,12 +401,12 @@ public class AccountIT extends AbstractDaemonTest {
public void updateNonExistingAccount() throws Exception { public void updateNonExistingAccount() throws Exception {
Account.Id nonExistingAccountId = new Account.Id(999999); Account.Id nonExistingAccountId = new Account.Id(999999);
AtomicBoolean consumerCalled = new AtomicBoolean(); AtomicBoolean consumerCalled = new AtomicBoolean();
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update( .update(
"Update Non-Existing Account", nonExistingAccountId, a -> consumerCalled.set(true)); "Update Non-Existing Account", nonExistingAccountId, a -> consumerCalled.set(true));
assertThat(account).isNull(); assertThat(accountState).isNull();
assertThat(consumerCalled.get()).isFalse(); assertThat(consumerCalled.get()).isFalse();
} }
@@ -416,13 +416,13 @@ public class AccountIT extends AbstractDaemonTest {
assertUserBranchWithoutAccountConfig(anonymousCoward.getId()); assertUserBranchWithoutAccountConfig(anonymousCoward.getId());
String status = "OOO"; String status = "OOO";
Account account = AccountState accountState =
accountsUpdate accountsUpdate
.create() .create()
.update("Set status", anonymousCoward.getId(), u -> u.setStatus(status)); .update("Set status", anonymousCoward.getId(), u -> u.setStatus(status));
assertThat(account).isNotNull(); assertThat(accountState).isNotNull();
assertThat(account.getFullName()).isNull(); assertThat(accountState.getAccount().getFullName()).isNull();
assertThat(account.getStatus()).isEqualTo(status); assertThat(accountState.getAccount().getStatus()).isEqualTo(status);
assertUserBranch(anonymousCoward.getId(), null, status); assertUserBranch(anonymousCoward.getId(), null, status);
} }
@@ -1942,13 +1942,15 @@ public class AccountIT extends AbstractDaemonTest {
// metaId is set when account is created // metaId is set when account is created
AccountsUpdate au = accountsUpdate.create(); AccountsUpdate au = accountsUpdate.create();
Account.Id accountId = new Account.Id(seq.nextAccountId()); Account.Id accountId = new Account.Id(seq.nextAccountId());
Account account = au.insert("Create Test Account", accountId, u -> {}); AccountState accountState = au.insert("Create Test Account", accountId, u -> {});
assertThat(account.getMetaId()).isEqualTo(getMetaId(accountId)); assertThat(accountState.getAccount().getMetaId()).isEqualTo(getMetaId(accountId));
// metaId is set when account is updated // metaId is set when account is updated
Account updatedAccount = au.update("Set Full Name", accountId, u -> u.setFullName("foo")); AccountState updatedAccountState =
assertThat(account.getMetaId()).isNotEqualTo(updatedAccount.getMetaId()); au.update("Set Full Name", accountId, u -> u.setFullName("foo"));
assertThat(updatedAccount.getMetaId()).isEqualTo(getMetaId(accountId)); assertThat(accountState.getAccount().getMetaId())
.isNotEqualTo(updatedAccountState.getAccount().getMetaId());
assertThat(updatedAccountState.getAccount().getMetaId()).isEqualTo(getMetaId(accountId));
} }
private EmailInput newEmailInput(String email, boolean noConfirmation) { private EmailInput newEmailInput(String email, boolean noConfirmation) {
@@ -2049,11 +2051,12 @@ public class AccountIT extends AbstractDaemonTest {
assertThat(accountInfo.status).isNull(); assertThat(accountInfo.status).isNull();
assertThat(accountInfo.name).isNotEqualTo(fullName); assertThat(accountInfo.name).isNotEqualTo(fullName);
Account updatedAccount = update.update("Set Full Name", admin.id, u -> u.setFullName(fullName)); AccountState updatedAccountState =
update.update("Set Full Name", admin.id, u -> u.setFullName(fullName));
assertThat(doneBgUpdate.get()).isTrue(); assertThat(doneBgUpdate.get()).isTrue();
assertThat(updatedAccount.getStatus()).isEqualTo(status); assertThat(updatedAccountState.getAccount().getStatus()).isEqualTo(status);
assertThat(updatedAccount.getFullName()).isEqualTo(fullName); assertThat(updatedAccountState.getAccount().getFullName()).isEqualTo(fullName);
accountInfo = gApi.accounts().id(admin.id.get()).get(); accountInfo = gApi.accounts().id(admin.id.get()).get();
assertThat(accountInfo.status).isEqualTo(status); assertThat(accountInfo.status).isEqualTo(status);
@@ -2158,7 +2161,7 @@ public class AccountIT extends AbstractDaemonTest {
assertThat(bgCounterA2.get()).isEqualTo(0); assertThat(bgCounterA2.get()).isEqualTo(0);
assertThat(gApi.accounts().id(admin.id.get()).get().status).isEqualTo("A-1"); assertThat(gApi.accounts().id(admin.id.get()).get().status).isEqualTo("A-1");
Account updatedAccount = AccountState updatedAccountState =
update.update( update.update(
"Set Status", "Set Status",
admin.id, admin.id,
@@ -2177,7 +2180,7 @@ public class AccountIT extends AbstractDaemonTest {
assertThat(bgCounterA1.get()).isEqualTo(1); assertThat(bgCounterA1.get()).isEqualTo(1);
assertThat(bgCounterA2.get()).isEqualTo(1); assertThat(bgCounterA2.get()).isEqualTo(1);
assertThat(updatedAccount.getStatus()).isEqualTo("B-2"); assertThat(updatedAccountState.getAccount().getStatus()).isEqualTo("B-2");
assertThat(accounts.get(admin.id).getAccount().getStatus()).isEqualTo("B-2"); assertThat(accounts.get(admin.id).getAccount().getStatus()).isEqualTo("B-2");
assertThat(gApi.accounts().id(admin.id.get()).get().status).isEqualTo("B-2"); assertThat(gApi.accounts().id(admin.id.get()).get().status).isEqualTo("B-2");
} }