+ Start a Discussion
Rabbani sayyed 8Rabbani sayyed 8 

Can anyone help me with test class for below class, here class is about updating the opportunity status value to approved when the external review object(FC_Reviewer__External_Review__c) status values are updated? i am unable to cover this class?any help?

 Public static void UpdateStatus (List<FC_Reviewer__External_Review__c> ExtRevLst ) {
        Set<Id> setOpptyIds = new Set<Id>();
        Map<Id,List<FC_Reviewer__External_Review__c>> OpptyFCRMap =new Map<Id,List<FC_Reviewer__External_Review__c>>();
        Integer i=0;
        Set<Id> ApprovedOppty = new Set<Id>();      
        List<Opportunity> Opplist = new List<Opportunity>();

        for (FC_Reviewer__External_Review__c extreve :ExtRevLst)
        {

        if(extreve.FC_Reviewer__Status__c == 'Review Submitted' && extreve.Approved__c =='Yes')  {
             setOpptyIds.add(extreve.FC_Reviewer__Opportunity__c);
        }
   
        }
        
        for(FC_Reviewer__External_Review__c FCR:[SELECT id,FC_Reviewer__Opportunity__c,FC_Reviewer__Status__c,Approved__c FROM FC_Reviewer__External_Review__c WHERE FC_Reviewer__Opportunity__c IN :setOpptyIds]){
         If(!OpptyFCRMap.containskey(FCR.FC_Reviewer__Opportunity__c))
         {
             OpptyFCRMap.put(FCR.FC_Reviewer__Opportunity__c,new List<FC_Reviewer__External_Review__c>{FCR});
         }else
         {
             OpptyFCRMap.get(FCR.FC_Reviewer__Opportunity__c).add(FCR);
         }        
        }   
         
         For(Opportunity Opp: [Select Id,Stagename from opportunity where id in :OpptyFCRMap.keyset()])
         {
             Integer Size=OpptyFCRMap.get(Opp.id).Size();
             System.debug('Size++++++'+Size);
             For(FC_Reviewer__External_Review__c FCR:OpptyFCRMap.get(Opp.id))
             {
                 
                 If(FCR.FC_Reviewer__Status__c== 'Review Submitted' || FCR.Approved__c=='Yes')
                 {
                     i++;
                     System.debug('i++++++'+i);
                 }

             }
             System.debug('i++++++'+i);
             If(i==Size)
             {
              ApprovedOppty.add(Opp.id);
             }
             
         }
        
         For(Opportunity Opp: [Select Id,Stagename from opportunity where id in :ApprovedOppty])
         {
           Opp.Stagename='Approved';
           Opplist.add(Opp);
         }
         
     
    update Opplist;
}
}
cloudSavvyProgcloudSavvyProg
Hi Rabbani,

Please paste your test class here to help you further. And also tell us know how much code coverage are you getting currently?

Regards,
CloudSavvyProg