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

Need test class for following method

Hi Friends, Thanks in advance

I need test class for following method please any body help me reagrding below code.
private static void OppLineItemSchedule(Map < Id, Opportunity > oppList) {
        List < OpportunityLineItem > oppProductLines = [SELECT Station__c, Product_Name__c, Revenue_Category__c, Revenue_Type__c,
            Quantity__c, OpportunityId, Market__c, PricebookEntryId, UnitPrice,
            Amount_Input__c, Start_Date__c, End_Date__c,
            Opportunity.Agency_Commission__c, Opportunity.Synced_Proposal__c
            FROM OpportunityLineItem
            WHERE OpportunityId IN: oppList.values()

        Map < Id, List < OpportunityLineItem >> mapOppLines = new Map < Id, List < OpportunityLineItem >> ();

        for (OpportunityLineItem oli: oppProductLines) {
            if (!String.isBlank(oli.Opportunity.Synced_Proposal__c)) {
                if (mapOppLines.containsKey(oli.Opportunity.Synced_Proposal__c)) {
                } else {
                    mapOppLines.put(oli.Opportunity.Synced_Proposal__c, new List < OpportunityLineItem > {

        if (mapOppLines.size() > 0) {
            List<OpportunityLineItem> oliToDelete = new List<OpportunityLineItem>();
            for (List<OpportunityLineItem> olis : mapOppLines.values()) 


Thanks & regards
Atul GuptaAtul Gupta
Hi Rohitha, have you tried creating a test class yourself. Let me know with a sample of your test class where exactly are you stuck.
Anupam KhasiaAnupam Khasia
Hi Rohitha,

I will advise you to go through below links & create by yourself.

Ajay K DubediAjay K Dubedi
Hi Rohitha, 
 For this method you have to create a map(Id,Opportunity) in your test class & pass that in the method's parameter while calling it in your test class & for the conditional blocks you have to insert those records which fulfill the conditions in your IF blocks otherwise it will not cover the code present in the IF blocks.