public void testReRegisterSucceedsOnNonExistingAccount() throws PersistenceException, RobotRegistrationException { registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).putAccount(any(RobotAccountData.class)); } }
public void testReRegisterSucceedsOnNonExistingAccount() throws PersistenceException, RobotRegistrationException { registrar.registerOrUpdate(ROBOT_ID, OTHER_LOCATION); verify(accountStore).putAccount(any(RobotAccountData.class)); } }
/** * Ensures that the robot agent is registered in the {@link AccountStore}. */ private void ensureRegistered(String serverFrontendAddress) { ParticipantId robotId; try { robotId = ParticipantId.of(getRobotId() + "@" + waveDomain); } catch (InvalidParticipantAddress e) { LOG.log(Level.SEVERE, "Failed to register the agent:" + getRobotId(), e); return; } try { String location = serverFrontendAddress + getRobotUri(); // In order to re-register the agents if the server frontend address has changed. robotRegistrar.registerOrUpdate(robotId, location); } catch (RobotRegistrationException | PersistenceException e) { LOG.log(Level.SEVERE, "Failed to register the agent:" + getRobotId(), e); } }
public void testReRegisterFailsOnExistingHumanAccount() throws PersistenceException { when(accountStore.getAccount(HUMAN_ID)).thenReturn( new HumanAccountDataImpl(ParticipantId.ofUnsafe(HUMAN_ID.getAddress()))); try { registrar.registerOrUpdate(HUMAN_ID, OTHER_LOCATION); fail(); } catch (RobotRegistrationException e) { // Expected. } }
public void testReRegisterFailsOnExistingHumanAccount() throws PersistenceException { when(accountStore.getAccount(HUMAN_ID)).thenReturn( new HumanAccountDataImpl(ParticipantId.ofUnsafe(HUMAN_ID.getAddress()))); try { registrar.registerOrUpdate(HUMAN_ID, OTHER_LOCATION); fail(); } catch (RobotRegistrationException e) { // Expected. } }
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()); }