I am trying to write a test class to test if a chatter post was actually posted. This is the code to test:

VantageConnectorTestMessage__c vctm = VantageConnectorTestMessage__c.getValues('TestMessage1');

String mess = vctm.Message__c;

ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), UserInfo.getUserId(), ConnectApi.FeedElementType.FeedItem, mess);

I was trying to get the feed element and test if it was not null:

ConectApi.FeedElementPage = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(Network.getNetworkID(),ConnectApi.FeedElementType.FeedItem);

But then I read some more here and I cant tell the difference between getFeed and getFeedElement..

getFeed(communityId, feedType, subjectId)

Returns the feed for the specified feed type for the specified user.

getFeedElement(communityId, feedElementId)

Returns information about the specified feed element.

does anyone know which one I want here ?

  • IIRC you can't really test that the ConnectAPI inserts any records because it uses callouts. – Adrian Larson Jun 4 '18 at 14:29
  • Could you please elaborate – SallyRothroat Jun 4 '18 at 14:33
  • If that's true cant I use a dummy rest response, as seen in trailhead, that is somehow adapted to chatter in order to test that posting works. – SallyRothroat Jun 4 '18 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.