function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ajay RanawatAjay Ranawat 

Test Coverage for ConnectApi.FeedItemPage in Version 34

I have to test cover this line: 
ConnectApi.FeedItemPage items = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null, ConnectApi.FeedType.News, 'me');
Here is my test class:

@isTest private class NewsFeedClassTest {
@IsTest static void doTest() {
// Build a simple feed item
ConnectApi.FeedItemPage testPage = new ConnectApi.FeedItemPage();
List<ConnectApi.FeedItem> testItemList = new List<ConnectApi.FeedItem>();
testItemList.add(new ConnectApi.FeedItem());
testItemList.add(new ConnectApi.FeedItem());
testPage.items = testItemList;

This works fine with Version 30, but whenever I change to version 34 of apex it givers deprecated property error, any one knows how to test cover the following lines of code??

Thanks & Regards,


In v34.0, ConnectApi.ChatterFeeds.getFeedItemsFromFeed(...) doesn't exist. Instead, you need to use ConnectApi.ChatterFeeds.getFeedElementsFromFeed(...), which returns a ConnectApi.FeedElementPage.

For more info, the docs are at: