You need to sign in to do that
Don't have an account?
Miguel Roa
How would you go about making a test class for this
Any help whit a test class for this class please, I can't find any example on the internet.
Thanks
public without sharing class OpportunityUpdate_WithDVSSCaseHelper { public static void UpdateOpptyStatusForOpptyWithDVSSCases_OnPegaSide(List<Opportunity> newOppty,Map<Id,Opportunity> oldOppty){ Map<String,String> DvssCaseTypes = new Map<String,String>(); DvssCaseTypes.put('DVSS AM', 'DVSSAM'); DvssCaseTypes.put('DVSS CPE','DVSSCPE'); DvssCaseTypes.put('DVSS DR','DVSSDR'); DvssCaseTypes.put('DVSS RFP','DVSSRFP'); List<Id> opptyIds = new List<Id>(); List<Opportunity> opptiesToUpdateOnPega; List<WrapperDVSSOpptyStageUpdateService> wrappers = new List<WrapperDVSSOpptyStageUpdateService>(); for(Opportunity oppty:newOppty){ Opportunity oldOp = oldOppty.get(oppty.Id); if(oppty.StageName != oldOp.StageName && (oppty.StageName =='5 Closed Lost' || oppty.StageName =='5 Closed Disqualified' ) ){ opptyIds.add(oppty.Id); } } if(opptyIds.size() > 0){ opptiesToUpdateOnPega = [select Id,StageName,(SELECT Case_Type__c,SWAP_Case_ID__c FROM SWAPS_Tracker__r where case_type__c in ('DVSS AM','DVSS CPE','DVSS DR','DVSS RFP')) from Opportunity where Id in:opptyIds and Id in(select Opportunity_Name__c from SWAP_Tracker__c where Opportunity_Name__c in:opptyIds and case_type__c in ('DVSS AM','DVSS CPE','DVSS DR','DVSS RFP')) ]; if(opptiesToUpdateOnPega.size() > 0){ for(Opportunity opp:opptiesToUpdateOnPega){ List<SWAP_Tracker__c> swTrack = opp.SWAPS_Tracker__r; system.debug('Oppt info LP>> ' + opp); DateTime dtvar = null; String Casetype='' ; String CaseId=''; string OpptyStatus = opp.StageName; for(SWAP_Tracker__c swt:swTrack){ Casetype = (DvssCaseTypes.get(swt.Case_Type__c) == null)?'':DvssCaseTypes.get(swt.Case_Type__c); CaseId = (swt.SWAP_Case_ID__c ==null)?'':swt.SWAP_Case_ID__c; WrapperDVSSOpptyStageUpdateService wp = new WrapperDVSSOpptyStageUpdateService(); wp.Casetype = Casetype; wp.CaseId = CaseId; wp.OpptyStatus = OpptyStatus; wrappers.add(wp); } } } } } }
Thanks
From my understanding, this class appears to be responsible for updating certain Opportunity records based on their StageName and related SWAPS_Tracker__c records with specific case types.
Example code to get started:
You need to customize this as per your requirements.
Related:
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines
https://salesforce.stackexchange.com/questions/68396/test-class-for-opportunity-update
https://www.sfdckid.com/2019/09/apex-test-class-for-trigger-part-1-salesforce.html?m=1
Thanks