CollectionTimeline extends BaseTimeline implements Timeline<Tweet> { static TimelineCursor getTimelineCursor(TwitterCollection twitterCollection) { if (twitterCollection == null || twitterCollection.metadata == null || twitterCollection.metadata.position == null) { return null; } final Long minPosition = twitterCollection.metadata.position.minPosition; final Long maxPosition = twitterCollection.metadata.position.maxPosition; return new TimelineCursor(minPosition, maxPosition); } CollectionTimeline(TwitterCore twitterCore, Long collectionId, Integer maxItemsPerRequest); @Override void next(Long minPosition, Callback<TimelineResult<Tweet>> cb); @Override void previous(Long maxPosition, Callback<TimelineResult<Tweet>> cb);  }
@Test public void testGetTimelineCursor() { final TwitterCollection.Content contents = new TwitterCollection.Content(testTweetMap, testUserMap); final TwitterCollection.Metadata metadata = new TwitterCollection.Metadata("", TEST_POSITION, testItems); final TimelineCursor cursor = CollectionTimeline.getTimelineCursor( new TwitterCollection(contents, metadata)); assertEquals(TEST_MAX_POSITION, cursor.maxPosition); assertEquals(TEST_MIN_POSITION, cursor.minPosition); }
@Test public void testGetTimelineCursor_handlesNull() { TwitterCollection collection = new TwitterCollection(new TwitterCollection.Content(null, testUserMap), new TwitterCollection.Metadata("", null, testItems)); TimelineCursor timelineCursor = CollectionTimeline.getTimelineCursor(collection); assertNull(timelineCursor); collection = new TwitterCollection(new TwitterCollection.Content(null, testUserMap), null); timelineCursor = CollectionTimeline.getTimelineCursor(collection); assertNull(timelineCursor); timelineCursor = CollectionTimeline.getTimelineCursor(null); assertNull(timelineCursor); }