I have retrieved a FeedElement by it's postId. I now want to test that the feed.body is a certain value. FeedElement.Body is of type FeedBody. This is the documentation for FeedBody which as you can see doesn't say much. What is the best way to turn a FeedBody into a string ?

ConnectApi.FeedElement testPost = ConnectApi.ChatterFeeds.getFeedElement(Network.getNetworkId(),postId);
String testMessage = vct.getTestMessage();

FeedBody is a concrete subclass of ConnectApi.AbstractMessageBody.

That class has a property text that's inherited by FeedBody, which you should be able to access and make assertions against. It's of type String. (Unless you want to iterate through the message segments to validate a user mention or something like that).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.