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
Miguel RoaMiguel 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.
 
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
SwethaSwetha (Salesforce Developers) 
HI Miguel,
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:
@isTest
private class OpportunityUpdate_WithDVSSCaseHelperTest {
    @isTest
    static void testUpdateOpptyStatusForOpptyWithDVSSCases_OnPegaSide() {
        // Create test data
        Account testAccount = new Account(Name = 'Test Account');
        insert testAccount;
        Opportunity testOppty = new Opportunity(Name = 'Test Opportunity', StageName = '1 Prospecting', CloseDate = Date.today(), AccountId = testAccount.Id);
        insert testOppty;
        SWAP_Tracker__c testSWAPTracker = new SWAP_Tracker__c(Opportunity_Name__c = testOppty.Id, Case_Type__c = 'DVSS AM', SWAP_Case_ID__c = '12345');
        insert testSWAPTracker;
        List<Opportunity> newOppty = new List<Opportunity>{ testOppty };
        Map<Id, Opportunity> oldOppty = new Map<Id, Opportunity>{ testOppty.Id => testOppty };
        
        // Call the helper method
        OpportunityUpdate_WithDVSSCaseHelper.UpdateOpptyStatusForOpptyWithDVSSCases_OnPegaSide(newOppty, oldOppty);
        
        // Verify the results
        List<WrapperDVSSOpptyStageUpdateService> wrappers = new List<WrapperDVSSOpptyStageUpdateService>();
        for (SWAP_Tracker__c swt : [SELECT Id, Opportunity_Name__c, Case_Type__c, SWAP_Case_ID__c FROM SWAP_Tracker__c WHERE Opportunity_Name__c = :testOppty.Id AND Case_Type__c = 'DVSS AM']) {
            WrapperDVSSOpptyStageUpdateService wp = new WrapperDVSSOpptyStageUpdateService();
            wp.Casetype = 'DVSSAM';
            wp.CaseId = '12345';
            wp.OpptyStatus = '1 Prospecting';
            wrappers.add(wp);
        }
        System.assertEquals(wrappers.size(), 1);
    }
}

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