Examples of RobotAccountData


Examples of org.waveprotocol.box.server.account.RobotAccountData

    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());
  }
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

    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());
  }
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

    verify(robot).run();
  }

  public void testUpdateRobotAccount() throws Exception {
    Robot robot = mock(Robot.class);
    RobotAccountData account = mock(RobotAccountData.class);
    when(robot.getAccount()).thenReturn(account);

    // Return newAccount when updated
    RobotAccountData newAccount = mock(RobotAccountData.class);
    when(robotConnector.fetchCapabilities(eq(account), any(String.class))).thenReturn(newAccount);

    gateway.updateRobotAccount(robot);

    verify(accountStore).putAccount(newAccount);
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

  }

  public void testFetchCapabilities() throws Exception {
    when(connection.get(TEST_CAPABILITIES_ENDPOINT)).thenReturn(CAPABILITIES_XML);

    RobotAccountData accountData = connector.fetchCapabilities(ROBOT_ACCOUNT, "");

    RobotCapabilities capabilities = accountData.getCapabilities();
    assertEquals("Expected capabilities hash as specified in the xml", CAPABILITIES_HASH,
        capabilities.getCapabilitiesHash());
    assertEquals("Expected protocol version as specified in the xml", ProtocolVersion.V2_2,
        capabilities.getProtocolVersion());
    Map<EventType, Capability> capabilitiesMap = capabilities.getCapabilitiesMap();
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

   * @param id the participant id of the new user.
   * @throws IOException if there is a problem submitting the new wave.
   */
  public void greet(ParticipantId id) throws IOException {
    Preconditions.checkNotNull(id);
    RobotAccountData account = null;
    String rpcUrl = getFrontEndAddress() + "/robot/rpc";
    try {
      account =
        getAccountStore()
        .getAccount(ParticipantId.ofUnsafe(getRobotId() + "@" + getWaveDomain())).asRobot();
    } catch (PersistenceException e) {
      LOG.log(Level.WARNING, "Cannot fetch account data for robot id: " + getRobotId(), e);
    }
    if (account != null) {
      setupOAuth(account.getId().getAddress(), account.getConsumerSecret(), rpcUrl);
      Wavelet newWelcomeWavelet = newWave(getWaveDomain(), Sets.newHashSet(id.getAddress()));
      if (welcomeWaveId != null) {
        Wavelet templateWelcomeWavelet =
          fetchWavelet(welcomeWaveId, WaveletId.of(getWaveDomain(), "conv+root"), rpcUrl);
        RobotsUtil.copyBlipContents(templateWelcomeWavelet.getRootBlip(),
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

        LOG.severe("Failed to retrieve the account data for " + robotId.getAddress(), e);
        continue;
      }

      if (account != null && account.isRobot()) {
        RobotAccountData robotAccount = account.asRobot();
        if (robotAccount.isVerified()) {
          Robot robot = getOrCreateRobot(robotName, robotAccount);
          updateRobot(robot, wavelet, deltas);
        }
      }
    }
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

   */
  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);
  }
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

    } catch (InvalidParticipantAddress e) {
      doRegisterGet(req, resp, "Invalid username specified, use alphanumeric characters only.");
      return;
    }

    RobotAccountData robotAccount = null;
    try{
      robotAccount = robotRegistrar.registerNew(id, location);
    } catch (RobotRegistrationException e) {
      doRegisterGet(req, resp, e.getMessage());
      return;
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

    if (account == null || !account.isRobot()) {
      throw new InvalidRequestException("Can't exectute robot.notify for unknown robot "
          + robotAccountId);
    }

    RobotAccountData robotAccountData = account.asRobot();
    RobotCapabilities capabilities = robotAccountData.getCapabilities();
    if (capabilities != null && capabilitiesHash.equals(capabilities.getCapabilitiesHash())) {
      // No change in capabilities indicated
      context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap());
      return;
    }
View Full Code Here

Examples of org.waveprotocol.box.server.account.RobotAccountData

    AccountData accountData = accountStore.getAccount(robotId);
    if (accountData == null) {
      return null;
    }
    throwExceptionIfNotRobot(accountData);
    RobotAccountData robotAccount = accountData.asRobot();
    removeRobotAccount(robotAccount);
    return robotAccount;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.