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
sfdc@isha.ax1814sfdc@isha.ax1814 

testclass for custommetadata apexclass -urgent need help

Please help with testclass for below class.

public static void handleAfterUpdateUpdatedate(List<Product__c> listNewProducts, map<ID, Product__c> mapOldProducts){
    
     List<Product__c> ProductList = new List<Product__c>();
                     Product__c pd = new Product__c();
                     public static map<String, Statute_Date_Update__mdt> mapstatueMetadata = Statute_Date_Update__mdt.getAll();
                   for(Product__c prod : listNewProducts){ 
                   Product__c prodOld12 = mapOldProducts.get(prod.Id);
                
                    if((prod.Last_Payment_Date__c != prodOld12.Last_Payment_Date__c) ||( prod.Open_Date__c != prodOld12.Open_Date__c) )

        {
        if(prod.Statute_Date__c > prod.Date_for_Stat_Barred_calculations__c){
        if(prod.Date_for_Stat_Barred_calculations__c!=null){
                    
                            Map<String, Statute_Date_Update__mdt> mtdMap = new Map<String, Statute_Date_Update__mdt>();
                       // List<Statute_Date_Update__mdt> mtData = [Select Id, MasterLabel, Months__c From Statute_Date_Update__mdt];
                        for(Statute_Date_Update__mdt m:mapstatueMetadata.values()){
                            mtdMap.put(m.MasterLabel, m);
                        }
                    
                     system.debug('mtdMap## ' + mtdMap);
        
            if(mtdMap.containsKey(prod.State__c) && prod.State__c !=prodOld12.State__c){
                    
        Integer i= Integer.valueof(mtdMap.get(prod.State__c).Months__c);
                
                pd.Id = prod.Id;
             pd.Statute_Date__c = prod.Date_for_Stat_Barred_calculations__c.addMonths(i);
                ProductList.add(pd);
            }
        }
        }
        }
        }
        if(!ProductList.isEmpty()){
            update ProductList;
        }
    }
SwethaSwetha (Salesforce Developers) 
HI Isha,

The question does not include which lines of code are uncovered.The below information should help you get started with writing test classes.
 
https://salesforce.stackexchange.com/questions/244788/how-do-i-write-an-apex-unit-test
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines 


Thanks