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
RIteshMRIteshM 

Testing Batch apex code with two batches

i am trying to test a trigger my trigger code is 

 

trigger PostFeedsToTimeLine on FeedItem (after insert) {
Map<String,String> contentMap = new Map<String,String>{'Object' =>'FeedItem','Content' =>'Body'};
if(Trigger.new.size() > 5){
BatchPublishTimeLine publishBatch = new BatchPublishTimeLine(Trigger.new,contentMap);
Database.executeBatch(publishBatch,5);
}
else GMirrorUtil.createTimeLine(Trigger.new, contentMap);
}

 

batch will always get created if size is greater than 5 but when size is greater than 5 two batch will get executed  what to do.in batch i am calling GMirrorUtil.createTimeLine which is making two callouts thats why this 5 limit .what to do in this case ?? because maximum 5 batch can be queued thats why if possible i try to make it without batch but in cases when more than 5 then i execute it using Batch.