@Test
  public void getJohnDoeFriendsOrderedByName() throws Exception {
    // Set collection options
    CollectionOptions collectionOptions = new CollectionOptions();
    collectionOptions.setSortBy("name");
    collectionOptions.setSortOrder(SortOrder.ascending);
    collectionOptions.setMax(20);

    // Get all friends of john.doe
    Future<RestfulCollection<Person>> result =
        this.personServiceDb.getPeople(
            SpiTestUtil.buildUserIds("john.doe"),
            new GroupId(GroupId.Type.friends, "@friends"),
            collectionOptions,
            Person.Field.ALL_FIELDS,
            SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);

    RestfulCollection<Person> peopleCollection = result.get();
    assertEquals(3, peopleCollection.getTotalResults());
    assertEquals(0, peopleCollection.getStartIndex());
    List<Person> people = peopleCollection.getEntry();
    // The users should be in alphabetical order
    SpiTestUtil.assertPersonEquals(people.get(0), "george.doe", "George Doe");
    SpiTestUtil.assertPersonEquals(people.get(1), "jane.doe", "Jane Doe");
  }
 public void testGetExpectedActivitiesForPlural() throws Exception {
   RestfulCollection<Activity> responseItem =
       db.getActivities(
               ImmutableSet.of(CANON_USER, JOHN_DOE),
               SELF_GROUP,
               APP_ID,
               Collections.<String>emptySet(),
               null,
               new FakeGadgetToken())
           .get();
   assertSame(3, responseItem.getTotalResults());
 }
  public void testGetExpectedUsersForPlural() 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> responseItem =
        db.getPeople(
                ImmutableSet.of(JOHN_DOE, JANE_DOE),
                new GroupId(GroupId.Type.friends, null),
                options,
                Collections.<String>emptySet(),
                token)
            .get();
    assertNotNull(responseItem);
    assertEquals(4, responseItem.getTotalResults());
    // Test a couple of users
    assertEquals("john.doe", responseItem.getEntry().get(0).getId());
    assertEquals("jane.doe", responseItem.getEntry().get(1).getId());
  }