@Override protected void setUp() throws Exception { accountStore = mock(AccountStore.class); tokenGenerator = mock(TokenGenerator.class); accountData = mock(RobotAccountData.class); when(accountData.isRobot()).thenReturn(true); when(accountData.asRobot()).thenReturn(accountData); when(accountData.getUrl()).thenReturn(LOCATION); when(accountData.getId()).thenReturn(ROBOT_ID); when(tokenGenerator.generateToken(anyInt())).thenReturn(CONSUMER_TOKEN); registrar = new RobotRegistrarImpl(accountStore, tokenGenerator); }
@Override protected void setUp() throws Exception { accountStore = mock(AccountStore.class); tokenGenerator = mock(TokenGenerator.class); accountData = mock(RobotAccountData.class); when(accountData.isRobot()).thenReturn(true); when(accountData.asRobot()).thenReturn(accountData); when(accountData.getUrl()).thenReturn(LOCATION); when(accountData.getId()).thenReturn(ROBOT_ID); when(tokenGenerator.generateToken(anyInt())).thenReturn(CONSUMER_TOKEN); registrar = new RobotRegistrarImpl(accountStore, tokenGenerator); }
public void testRegisterNewSucceeds() throws PersistenceException, RobotRegistrationException { RobotAccountData resultAccountData = registrar.registerNew(ROBOT_ID, LOCATION); verify(accountStore, atLeastOnce()).getAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); verify(tokenGenerator).generateToken(anyInt()); assertTrue(resultAccountData.isRobot()); RobotAccountData robotAccountData = resultAccountData.asRobot(); // Remove the last '/'. assertEquals(LOCATION.substring(0, LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }
public void testRegisterNewSucceeds() throws PersistenceException, RobotRegistrationException { RobotAccountData resultAccountData = registrar.registerNew(ROBOT_ID, LOCATION); verify(accountStore, atLeastOnce()).getAccount(ROBOT_ID); verify(accountStore).putAccount(any(RobotAccountData.class)); verify(tokenGenerator).generateToken(anyInt()); assertTrue(resultAccountData.isRobot()); RobotAccountData robotAccountData = resultAccountData.asRobot(); // Remove the last '/'. assertEquals(LOCATION.substring(0, LOCATION.length() - 1), robotAccountData.getUrl()); assertEquals(ROBOT_ID, robotAccountData.getId()); assertEquals(CONSUMER_TOKEN, robotAccountData.getConsumerSecret()); }