/** * Removes the robot account and notifies the listeners. * @param existingAccount the account to remove * @throws PersistenceException if the persistence layer reports an error. */ private void removeRobotAccount(RobotAccountData existingAccount) throws PersistenceException { accountStore.removeAccount(existingAccount.getId()); for (Listener listener : listeners) { listener.onUnregistrationSuccess(existingAccount); } }
/** * Changes the user password. * * @param newPassword the new password of the user. * @param participantId the user wave address. * @param accountStore the account store with user accounts. * @throws PersistenceException if the persistence layer fails. * @throws IllegalArgumentException if the user doesn't exist. */ public static void changeUserPassword(String newPassword, ParticipantId participantId, AccountStore accountStore) throws PersistenceException, IllegalArgumentException { PasswordDigest newPasswordDigest = new PasswordDigest(newPassword.toCharArray()); HumanAccountDataImpl account = new HumanAccountDataImpl(participantId, newPasswordDigest); if (accountStore.getAccount(participantId) != null) { accountStore.removeAccount(participantId); accountStore.putAccount(account); } else { throw new IllegalArgumentException(String.format("User %s does not exist on this domain.", participantId.getAddress())); } }
public void testUnregisterSucceeds() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.unregister(ROBOT_ID); assertTrue(unregisteredAccountData.equals(accountData)); verify(accountData).isRobot(); verify(accountStore).removeAccount(ROBOT_ID); }
public void testUnregisterSucceeds() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.unregister(ROBOT_ID); assertTrue(unregisteredAccountData.equals(accountData)); verify(accountData).isRobot(); verify(accountStore).removeAccount(ROBOT_ID); }
public void testReRegisterSucceedsOnExistingRobotAccount() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).removeAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); assertTrue(unregisteredAccountData.isRobot()); RobotAccountData robotAccountData = unregisteredAccountData.asRobot(); // Remove the last '/'. assertEquals(OTHER_LOCATION.substring(0, OTHER_LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
public void testReRegisterSucceedsOnExistingRobotAccount() throws PersistenceException, RobotRegistrationException { when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData); AccountData unregisteredAccountData = registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).removeAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); assertTrue(unregisteredAccountData.isRobot()); RobotAccountData robotAccountData = unregisteredAccountData.asRobot(); // Remove the last '/'. assertEquals(OTHER_LOCATION.substring(0, OTHER_LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
public final void testRemoveAccount() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount(robotAccount); AccountData account = accountStore.getAccount(ROBOT_ID); assertEquals(robotAccount, account); accountStore.removeAccount(ROBOT_ID); assertNull("Removed account was not null", accountStore.getAccount(ROBOT_ID)); } }
public final void testRemoveAccount() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount(robotAccount); AccountData account = accountStore.getAccount(ROBOT_ID); assertEquals(robotAccount, account); accountStore.removeAccount(ROBOT_ID); assertNull("Removed account was not null", accountStore.getAccount(ROBOT_ID)); } }