/** * Creates a new {@link Robot}. * * @param robotName the name of the robot. * @param account the {@link RobotAccountData} belonging to the given * {@link RobotName}. */ private Robot createNewRobot(RobotName robotName, RobotAccountData account) { EventGenerator eventGenerator = new EventGenerator(robotName, conversationUtil); RobotOperationApplicator operationApplicator = new RobotOperationApplicator(converterManager, waveletProvider, new OperationServiceRegistryImpl(notifyOpService), conversationUtil); return new Robot(robotName, account, this, connector, converterManager, waveletProvider, eventGenerator, operationApplicator); }
@SuppressWarnings("unchecked") @Override protected void setUp() throws Exception { gateway = mock(RobotsGateway.class); connector = mock(RobotConnector.class); converterManager = mock(EventDataConverterManager.class); waveletProvider = mock(WaveletProvider.class); eventGenerator = mock(EventGenerator.class); operationApplicator = mock(RobotOperationApplicator.class); robot = new Robot(ROBOT_NAME, ACCOUNT, gateway, connector, converterManager, waveletProvider, eventGenerator, operationApplicator); // Set the initialized account when updateRobotAccount is called. doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { robot.setAccount(INITIALIZED_ACCOUNT); return null; } }).when(gateway).updateRobotAccount(robot); // Generate no events on default EventMessageBundle emptyMessageBundle = new EventMessageBundle(ROBOT_NAME.toEmailAddress(), ""); when(eventGenerator.generateEvents( any(WaveletAndDeltas.class), anyMap(), any(EventDataConverter.class))).thenReturn( emptyMessageBundle); }
@SuppressWarnings("unchecked") @Override protected void setUp() throws Exception { gateway = mock(RobotsGateway.class); connector = mock(RobotConnector.class); converterManager = mock(EventDataConverterManager.class); waveletProvider = mock(WaveletProvider.class); eventGenerator = mock(EventGenerator.class); operationApplicator = mock(RobotOperationApplicator.class); robot = new Robot(ROBOT_NAME, ACCOUNT, gateway, connector, converterManager, waveletProvider, eventGenerator, operationApplicator); // Set the initialized account when updateRobotAccount is called. doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { robot.setAccount(INITIALIZED_ACCOUNT); return null; } }).when(gateway).updateRobotAccount(robot); // Generate no events on default EventMessageBundle emptyMessageBundle = new EventMessageBundle(ROBOT_NAME.toEmailAddress(), ""); when(eventGenerator.generateEvents( any(WaveletAndDeltas.class), anyMap(), any(EventDataConverter.class))).thenReturn( emptyMessageBundle); }