/** * 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())); }
@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()); }
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()); }