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
Akshay Alandkar 8Akshay Alandkar 8 

test class for this one

public class populateDefaultReportDetailsForm implements Queueable, Database.AllowsCallouts { 
    
      public static final Map<String, Set<String>> GARDetailSectionsByFormName = new Map<String, Set<String>>{
            'GAR_GranteeLevelForm2021' => new Set<String>{
            },
            'GAR_SelfInspectionForm2021' => new Set<String>{
                    'Self-Inspection'
            },
            'GAR_OngoingComplianceReviewForm2021' => new Set<String>{
                    'Ongoing Compliance Review /Quality Control'
            },
            'LSC_GAR_ServiceAreaForm2021' => new Set<String>{
                    '1. Personnel Expenses',
                    '2. Non-Personnel Expenses',
                    '1. LSC Revenue',
                    '2. Non-LSC Revenue',
                    '3. Client Service Income',
                    'Staff Open Cases',
                    'PAI Open Cases',
                    'Gender',
                    'Veteran Status',
                    'Ethnicity',
                    'Language',
                    'Pro Bono',
                    'Compensated',
                    'Number of Group Clients'
            }
    };

      List<ProgressReportForm__c> progressReportForms = new List<ProgressReportForm__c> (); 
      public populateDefaultReportDetailsForm(List<ProgressReportForm__c> progressReportForms ) { 
        this.progressReportForms.addAll(progressReportForms);         
      } 

     public void execute(QueueableContext context) { 
        Set<String> sectionTypeSet = new Set<String>();
        for (Set<String> subset : GARDetailSectionsByFormName.values()) {
            sectionTypeSet.addAll(subset);
        }
        Map<String, List<LSC_ProgressReportDetail__c>> masterProgressReportsBySection = new Map<String, List<LSC_ProgressReportDetail__c>>();
        List<LSC_ProgressReportDetail__c> masterProgressReportDetails = LSC_GARProgressReportHelper.getMasterTemplateRecords(sectionTypeSet);
        for (LSC_ProgressReportDetail__c progressReportDetail : masterProgressReportDetails) {
            if (!masterProgressReportsBySection.containsKey(progressReportDetail.LSC_GAR_SectionType__c)) {
                masterProgressReportsBySection.put(progressReportDetail.LSC_GAR_SectionType__c, new List<LSC_ProgressReportDetail__c>());
            }
            masterProgressReportsBySection.get(progressReportDetail.LSC_GAR_SectionType__c).add(progressReportDetail);
        }
        List<LSC_ProgressReportDetail__c> relatedProgressReportDetails = new List<LSC_ProgressReportDetail__c>();
        for (ProgressReportForm__c progressReportForm : [SELECT Id,Name,ProgressReport__c,ConfigForm__c,ConfigForm__r.Name FROM ProgressReportForm__c WHERE Id IN:this.progressReportForms]) {
            if (!GARDetailSectionsByFormName.isEmpty() && GARDetailSectionsByFormName.get(progressReportForm.ConfigForm__r.Name) != null) {
                Set<String> sectionTypes = GARDetailSectionsByFormName.get(progressReportForm.ConfigForm__r.Name);
                if (!sectionTypes.isEmpty()) {
                    for (String sectionName : sectionTypes) {
                        if (!masterProgressReportsBySection.isEmpty() && masterProgressReportsBySection.get(sectionName) != null) {
                            List<LSC_ProgressReportDetail__c> masterProgressDetailList = masterProgressReportsBySection.get(sectionName);
                            for (LSC_ProgressReportDetail__c progressReportDetail : masterProgressDetailList) {
                                LSC_ProgressReportDetail__c prDetail = progressReportDetail.clone(false);
                                prDetail.Copied_From__c = progressReportDetail.Id;
                                prDetail.Is_Master__c = false;
                                prDetail.Progress_Report_Form__c = progressReportForm.Id;
                                relatedProgressReportDetails.add(prDetail);
                            }
                        }
                    }
                }
            }
        }
        if (!relatedProgressReportDetails.isEmpty()) {
            insert relatedProgressReportDetails;
        }
     }

}
AbhinavAbhinav (Salesforce Developers) 
Check this:

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!