@Test public void testGetFirstOfMany() throws Exception { List<String> words = Lists.newArrayList(firstWord, "goodbye", "blah"); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertEquals(firstWord, futureWord.get()); }
@Test public void testGetFirstOfSingle() throws Exception { List<String> words = Lists.newArrayList(firstWord); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertEquals(firstWord, futureWord.get()); }
@Test public void testGetFirstOfNone() throws Exception { List<String> words = Lists.newArrayList(new String[]{}); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertNull(futureWord.get()); } }
@Test public void testGetFirstOfNone() throws Exception { List<String> words = Lists.newArrayList(new String[]{}); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertNull(futureWord.get()); } }
@Test public void testGetFirstOfMany() throws Exception { List<String> words = Lists.newArrayList(firstWord, "goodbye", "blah"); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertEquals(firstWord, futureWord.get()); }
@Test public void testGetFirstOfSingle() throws Exception { List<String> words = Lists.newArrayList(firstWord); Future<RestfulCollection<String>> collection = ImmediateFuture.newInstance( new RestfulCollection<String>(words)); Future<String> futureWord = FutureUtil.getFirstFromCollection(collection); assertEquals(firstWord, futureWord.get()); }
@Test public void testHandleGetPlural() throws Exception { String path = "/people/john.doe,jane.doe/@self"; RestHandler operation = registry.getRestHandler(path, "GET"); List<Person> people = ImmutableList.of(); RestfulCollection<Person> data = new RestfulCollection<Person>(people); Set<UserId> userIdSet = Sets.newLinkedHashSet(JOHN_DOE); userIdSet.add(new UserId(UserId.Type.userId, "jane.doe")); expect(personService.getPeople(eq(userIdSet), eq(new GroupId(GroupId.Type.self, null)), eq(DEFAULT_OPTIONS), eq(DEFAULT_FIELDS), eq(token))).andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); }
@Test public void testHandleGetPlural() throws Exception { String path = "/activities/john.doe,jane.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activities = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activities); Set<UserId> userIdSet = Sets.newLinkedHashSet(JOHN_DOE); userIdSet.add(new UserId(UserId.Type.userId, "jane.doe")); org.easymock.EasyMock.expect(activityService.getActivities(eq(userIdSet), eq(new GroupId(GroupId.Type.self, null)), eq("appId"),eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA((CollectionOptions.class)), eq(token))).andReturn( Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activitystreams/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<ActivityEntry> entries = ImmutableList.of(); RestfulCollection<ActivityEntry> data = new RestfulCollection<ActivityEntry>(entries); org.easymock.EasyMock.expect(service.getActivityEntries(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activitystreams/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<ActivityEntry> entries = ImmutableList.of(); RestfulCollection<ActivityEntry> data = new RestfulCollection<ActivityEntry>(entries); org.easymock.EasyMock.expect(service.getActivityEntries(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(ImmediateFuture.newInstance(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
@Test public void testHandleGetFriendById() throws Exception { String path = "/people/john.doe/@friends/jane.doe"; RestHandler operation = registry.getRestHandler(path, "GET"); Person person = new PersonImpl(); List<Person> people = Lists.newArrayList(person); RestfulCollection<Person> data = new RestfulCollection<Person>(people); // TODO: We aren't passing john.doe to the service yet. expect(personService.getPeople( eq(ImmutableSet.of(new UserId(UserId.Type.userId, "jane.doe"))), eq(new GroupId(GroupId.Type.self, null)), eq(DEFAULT_OPTIONS), eq(DEFAULT_FIELDS), eq(token))) .andReturn(ImmediateFuture.newInstance(data)); replay(); assertEquals(person, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); }
@Test public void testBasicMethods() throws Exception { RestfulCollection<String> collection = new RestfulCollection<String>(Lists.<String>newArrayList()); List<String> entry = Lists.newArrayList("banana"); int startIndex = 5; int totalResults = 8675309; collection.setEntry(entry); collection.setStartIndex(startIndex); collection.setTotalResults(totalResults); assertEquals(entry, collection.getEntry()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); }
@Test public void testBasicMethods() throws Exception { RestfulCollection<String> collection = new RestfulCollection<String>(Lists.<String>newArrayList()); List<String> entryList = Lists.newArrayList("banana"); int startIndex = 5; int totalResults = 8675309; collection.setList(entryList); collection.setStartIndex(startIndex); collection.setTotalResults(totalResults); assertEquals(entryList, collection.getList()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); }
@Test public void testBasicMethods() throws Exception { RestfulCollection<String> collection = new RestfulCollection<String>(Lists.<String>newArrayList()); List<String> entryList = Lists.newArrayList("banana"); int startIndex = 5; int totalResults = 8675309; collection.setList(entryList); collection.setStartIndex(startIndex); collection.setTotalResults(totalResults); assertEquals(entryList, collection.getList()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); }
@Test public void testBasicMethods() throws Exception { RestfulCollection<String> collection = new RestfulCollection<String>(Lists.<String>newArrayList()); List<String> entryList = Lists.newArrayList("banana"); int startIndex = 5; int totalResults = 8675309; collection.setList(entryList); collection.setStartIndex(startIndex); collection.setTotalResults(totalResults); assertEquals(entryList, collection.getList()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); }
@Test public void testConstructors() throws Exception { List<String> entry = Lists.newArrayList("banana", "who"); RestfulCollection<String> collection = new RestfulCollection<String>(entry); assertEquals(entry, collection.getList()); assertEquals(0, collection.getStartIndex()); assertEquals(entry.size(), collection.getTotalResults()); assertEquals(entry.size(), collection.getItemsPerPage()); int startIndex = 9; int totalResults = 10; int resultsPerPage = 1; collection = new RestfulCollection<String>(entry, startIndex, totalResults, resultsPerPage); assertEquals(entry, collection.getList()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); assertEquals(resultsPerPage, collection.getItemsPerPage()); }
@Test public void testBasicMethods() throws Exception { RestfulCollection<String> collection = new RestfulCollection<String>(Lists.<String>newArrayList()); List<String> entry = Lists.newArrayList("banana"); int startIndex = 5; int totalResults = 8675309; collection.setEntry(entry); collection.setStartIndex(startIndex); collection.setTotalResults(totalResults); assertEquals(entry, collection.getEntry()); assertEquals(startIndex, collection.getStartIndex()); assertEquals(totalResults, collection.getTotalResults()); }