这是我的代码
public class ChatterFunction{
public ChatterFunction(){
LIST<ISSUE__C> issID = [SELECT Id, Name FROM ISSUE__C];
for(ISSUE__C i : issID){
postfeed(i.Id);
}
}
public static void postfeed(String iss){
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
mentionSegmentInput.id = '00528045147FTed';
messageBodyInput.messageSegments.add(mentionSegmentInput);
textSegmentInput.text = 'Something';
messageBodyInput.messageSegments.add(textSegmentInput);
feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
feedItemInput.subjectId = iss;
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(null,feedItemInput );
}
}
我尝试用代码
测试它@IsTest(SeeAllData=true) public static void testpostfeed() {
System.assertEquals(postfeed('a000l0013315hgr'),null);
}
但它显示错误消息:方法不存在或签名不正确:postfeed(String)
我不知道为什么它不存在....
答案 0 :(得分:0)
你的方法是静态的,所以你需要像这样调用它
System.assertEquals(ChatterFunction.postfeed('...'), null);