Package org.waveprotocol.box.server.account

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


    }
  }

  public void testUnregisterSucceeds() throws PersistenceException, RobotRegistrationException {
    when(accountStore.getAccount(ROBOT_ID)).thenReturn(accountData);
    AccountData unregisteredAccountData = registrar.unregister(ROBOT_ID);
    assertTrue(unregisteredAccountData.equals(accountData));
    verify(accountData).isRobot();
    verify(accountStore).removeAccount(ROBOT_ID);
  }
View Full Code Here


    }
  }

  public void testUnregisterNonExistingRobot() throws PersistenceException,
      RobotRegistrationException {
    AccountData unregisteredAccountData = registrar.unregister(ROBOT_ID);
    assertNull(unregisteredAccountData);
  }
View Full Code Here

  }

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

    return true;
  }

  public final void testHumanAccount() {
    ProtoAccountData data = ProtoAccountDataSerializer.serialize(humanAccount);
    AccountData account = ProtoAccountDataSerializer.deserialize(data);
    assertEquals(humanAccount, account);
  }
View Full Code Here

    assertEquals(humanAccount, account);
  }

  public final void testHumanAccountWithDigest() {
    ProtoAccountData data = ProtoAccountDataSerializer.serialize(humanAccountWithDigest);
    AccountData account = ProtoAccountDataSerializer.deserialize(data);
    assertEquals(humanAccountWithDigest, account);
  }
View Full Code Here

    assertEquals(humanAccountWithDigest, account);
  }

  public final void testRobotAccount() {
    ProtoAccountData data = ProtoAccountDataSerializer.serialize(robotAccount);
    AccountData account = ProtoAccountDataSerializer.deserialize(data);
    assertEquals(robotAccount, account);
  }
View Full Code Here

    assertEquals(robotAccount, account);
  }

  public final void testRobotAccountWithCapabilities() {
    ProtoAccountData data = ProtoAccountDataSerializer.serialize(robotAccountWithCapabilities);
    AccountData account = ProtoAccountDataSerializer.deserialize(data);
    assertEquals(robotAccountWithCapabilities, account);
  }
View Full Code Here

        // Not a valid robot name, next.
        continue;
      }

      ParticipantId robotId = ParticipantId.ofUnsafe(robotName.toEmailAddress());
      AccountData account;
      try {
        account = accountStore.getAccount(robotId);
      } catch (PersistenceException e) {
        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

        OperationUtil.getRequiredParameter(operation, ParamsProperty.CAPABILITIES_HASH);

    RobotName robotName = RobotName.fromAddress(participant.getAddress());

    ParticipantId robotAccountId = ParticipantId.ofUnsafe(robotName.toEmailAddress());
    AccountData account;
    try {
      account = accountStore.getAccount(robotAccountId);
    } catch (PersistenceException e) {
      LOG.severe("Failed to retreive account data for " + robotAccountId, e);
      context.constructErrorResponse(operation, "Unable to retrieve account data");
      return;
    }

    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;
    }

    try {
      robotAccountData = connector.fetchCapabilities(robotAccountData, "");
    } catch (CapabilityFetchException e) {
      LOG.fine("Unable to retrieve capabilities for " + account.getId(), e);
      context.constructErrorResponse(operation, "Unable to retrieve new capabilities");
      return;
    }

    try {
View Full Code Here

  @Override
  public RobotAccountData unregister(ParticipantId robotId) throws RobotRegistrationException,
      PersistenceException {
    Preconditions.checkNotNull(robotId);
    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

Related Classes of org.waveprotocol.box.server.account.AccountData

Copyright © 2018 www.massapicom. 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.