com.google.api.services.plus.model.ActivityFeed

Here are the examples of the java api class com.google.api.services.plus.model.ActivityFeed taken from open source projects.

1. TestGPlusUserActivityCollector#createMockActivityFeed()

View license
private static ActivityFeed createMockActivityFeed(int numBefore, int numAfter, int numInRange, DateTime after, DateTime before, boolean page) {
    ActivityFeed feed = new ActivityFeed();
    List<Activity> list = Lists.newLinkedList();
    for (int i = 0; i < numAfter; ++i) {
        DateTime published = before.plus(randomIntBetween(0, Integer.MAX_VALUE));
        Activity activity = createActivityWithPublishedDate(published);
        list.add(activity);
    }
    for (int i = 0; i < numInRange; ++i) {
        DateTime published = null;
        if ((before == null && after == null) || before == null) {
            // no date range or end time date range so just make the time now.
            published = DateTime.now();
        } else if (after == null) {
            //no beginning to range
            published = before.minusMillis(randomIntBetween(1, Integer.MAX_VALUE));
        } else {
            // has to be in range
            long range = before.getMillis() - after.getMillis();
            //in the middle
            published = after.plus(range / 2);
        }
        Activity activity = createActivityWithPublishedDate(published);
        activity.setTitle(IN_RANGE_IDENTIFIER);
        list.add(activity);
    }
    for (int i = 0; i < numBefore; ++i) {
        DateTime published = after.minusMillis(randomIntBetween(1, Integer.MAX_VALUE));
        Activity activity = createActivityWithPublishedDate(published);
        list.add(activity);
    }
    if (page) {
        feed.setNextPageToken("A");
    } else {
        feed.setNextPageToken(null);
    }
    feed.setItems(list);
    return feed;
}