• Saurav Prasad
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,
       My Helper class is given below:-
   /*
 *  Trigger Helper Class to parse image response
 *  Parse Image response From social post
 * */
public without sharing class ContentDocumentLinkTriggerHelper {
    public static List<ContentDocumentLink> newList;
    public static List<ContentDocumentLink> oldList;
    public static Map<Id, ContentDocumentLink> newMap;
    public static Map<Id, ContentDocumentLink> oldMap;
    
    public static Boolean runTrigger = true;
    // method to Parse Image response from social Post
    public static void parseImageResponse(){
        Set<Id> socialPostIds = new Set<Id>(newMap.keySet());
        List<Predictions__c> pdcList = new List<Predictions__c>();
        Set<Id> setLinkId = new Set<Id>();
        for(contentdocumentlink cdl : newList){
            if(String.valueOf((cdl.LinkedEntityId)).startsWith('0ST') && !setLinkId.contains(cdl.LinkedEntityId)){
                String jsonResponse = EinsteenPredictionService.getImagePrediction('test');
                EinsteenPredictionService ep= EinsteenPredictionService.parseImagePrediction(jsonResponse);
                for(EinsteenPredictionService.cls_probabilities result: ep.probabilities) {
                    Predictions__c    pc = new Predictions__c();
                    pc.Label__c = result.label;
                    pc.Probability__c = result.probability;
                    pc.Social_Post__c = cdl.LinkedEntityId;
                    pdcList.add(pc);
                }
                setLinkId.add(cdl.LinkedEntityId);
            }
        }
        //Check Prediction list Has value or not
        if(pdcList.size() > 0){
            insert pdcList; 
        }
    }
}
how to write test class for this helper class?
Any suggestions?