/**
  * Tests getPerson with a UserId typed as Userid. The Id string is set in the UserId.
  *
  * @throws Exception
  */
 @Test
 public void testGetExpectedPersonByUserId() throws Exception {
   Future<Person> selectedObject =
       personService.getPerson(JOHN_DOE, Collections.<String>emptySet(), new FakeGadgetToken());
   Person person = selectedObject.get();
   assertEquals(JOHN_DOE.getUserId(), person.getId());
 }
  /**
   * Tests getPeople with a couple of UserIds
   *
   * @throws Exception
   */
  @Test
  public void testGetExpectedPeople() throws Exception {
    CollectionOptions options = new CollectionOptions();
    options.setSortBy(PersonService.ALL_FILTER);
    options.setSortOrder(SortOrder.ascending);
    options.setFilter(null);
    options.setFilterOperation(FilterOperation.contains);
    options.setFilterValue("");
    options.setFirst(0);
    options.setMax(5);

    Set<UserId> userIds = new java.util.HashSet<UserId>();
    userIds.add(JOHN_DOE);
    userIds.add(JANE_DOE);
    userIds.add(MAIJA_M);

    RestfulCollection<Person> peopleCollection =
        personService
            .getPeople(
                userIds, null, options, Collections.<String>emptySet(), new FakeGadgetToken())
            .get();
    List<Person> personList = peopleCollection.getEntry();
    assertEquals(true, containsPerson(personList, JOHN_DOE.getUserId()));
    assertEquals(true, containsPerson(personList, MAIJA_M.getUserId()));
    assertEquals(false, containsPerson(personList, GEORGE_DOE.getUserId()));
  }
 /**
  * Tests getPerson with a UserId typed as Viewerid. The Id string is set in the token in the field
  * viewerId.
  *
  * @throws Exception
  */
 @Test
 public void testGetExpectedPersonByViewerId() throws Exception {
   SecurityToken token = FakeGadgetToken.createToken("viewerId=john.doe");
   Future<Person> selectedObject =
       personService.getPerson(VIEWER, Collections.<String>emptySet(), token);
   Person person = selectedObject.get();
   assertEquals(JOHN_DOE.getUserId(), person.getId());
 }
  @Test
  public void testGetExpectedFriends() throws Exception {
    CollectionOptions options = new CollectionOptions();
    options.setSortBy(PersonService.TOP_FRIENDS_SORT);
    options.setSortOrder(SortOrder.ascending);
    options.setFilter(null);
    options.setFilterOperation(FilterOperation.contains);
    options.setFilterValue("");
    options.setFirst(0);
    options.setMax(20);

    RestfulCollection<Person> friendsCollection =
        personService
            .getPeople(
                Sets.newHashSet(JOHN_DOE),
                new GroupId(GroupId.Type.friends, null),
                options,
                Collections.<String>emptySet(),
                new FakeGadgetToken())
            .get();
    assertEquals(4, friendsCollection.getEntry().size());
  }