@Override public Object answer(InvocationOnMock invocation) throws Throwable { robot.setAccount(INITIALIZED_ACCOUNT); return null; } }).when(gateway).updateRobotAccount(robot);
@Override public Object answer(InvocationOnMock invocation) throws Throwable { robot.setAccount(INITIALIZED_ACCOUNT); return null; } }).when(gateway).updateRobotAccount(robot);
/** * Constructs a new Robot which is characterized by its {@link RobotName}. * * @param robotName the name of the {@link Robot}. * @param account the {@link RobotAccountData} belonging to this * {@link Robot}. * @param gateway the gateway this robot belongs to. * @param connector the {@link RobotConnector} to make connections to * {@link Robot}s. * @param converterManager used to convert to Robot API objects. * @param waveletProvider used to access wavelets and submit deltas. * @param eventGenerator used to generate events * @param operationApplicator used to apply the robot operations returned by a * robot. */ Robot(RobotName robotName, RobotAccountData account, RobotsGateway gateway, RobotConnector connector, EventDataConverterManager converterManager, WaveletProvider waveletProvider, EventGenerator eventGenerator, RobotOperationApplicator operationApplicator) { Preconditions.checkArgument(account.isVerified(), "Account must be verified"); this.robotName = robotName; this.gateway = gateway; this.connector = connector; this.converterManager = converterManager; this.eventGenerator = eventGenerator; this.operationApplicator = operationApplicator; setAccount(account); }
/** * Updates the account for the given {@link Robot}. * * @param robot the {@link Robot} to update. * @throws CapabilityFetchException if the capabilities could not be fetched * or parsed. */ public void updateRobotAccount(Robot robot) throws CapabilityFetchException, PersistenceException { // TODO: Pass in activeAPIUrl String activeApiUrl = ""; RobotAccountData newAccount = connector.fetchCapabilities(robot.getAccount(), activeApiUrl); accountStore.putAccount(newAccount); robot.setAccount(newAccount); } }