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
newbiewithapexnewbiewithapex 

How do I cover part of the main class code in test class?

I have the Lead converter class and I am stuck on the part where the loop checks the LeadRecordType. Any help is much appreciated

This is the main class code

if (oppID != null) {
            Opportunity opp = [select id, RecordTypeId, StageName from opportunity where id = :oppID];
            system.debug('Initial StageName = ' + opp.StageName);
            //get the oppty "Prospect - Locally Manager" Record type id from custom settings
            if (recordTypeId != null) {

                //Updated by ADUA to have different record types for Opportunity from Converted leads as per Lead Record Type
                String oppRecordTypeId;

                if (leadRecordType.Name == 'ChefStore') {
                    oppRecordTypeId = recordTypeId.RecordType_Prospect_Locally_Managed__c;

                    opp.Type = 'Prospect Locally Managed';
                    //Updated by ADUA for SFS-1547  
                    // SSDR23-321 Prospect Locally Managed Opptys Probability is displaying wrong(%) if there is no stage selected.            
                    opp.StageName = STREET_STAGENAME;
                    //setting shiping date/close date
                    //opp.CloseDate = system.today() + 70;
                }
                else if (leadRecordType.Name == 'street') {
                    oppRecordTypeId = recordTypeId.RecordType_Prospect_Locally_Managed__c;

                    //Updated by ADUA for SFS-1114             
                    opp.Type = 'Prospect Locally Managed';
                    //Updated by ADUA for SFS-1547              
                    // SSDR23-321 Prospect Locally Managed Opptys Probability is displaying wrong(%) if there is no stage selected.
                    opp.StageName = STREET_STAGENAME;
                    opp.CloseDate = system.today() + 70;
                }
                else if (leadRecordType.Name == 'National') {
                    oppRecordTypeId = recordTypeId.RecordType_Prospect_Nationally_Managed__c;

                    //Updated by ADUA for SFS-1114             
                    opp.Type = 'Prospect Nationally Managed';
                    //Updated by ADUA for SFS-1547              
                    // SSDR23-321 Prospect Locally Managed Opptys Probability is displaying wrong(%) if there is no stage selected.
                    opp.StageName = NATIONAL_STAGENAME;
                }
                opp.RecordTypeId = oppRecordTypeId;
            }
            //opp.Type = CS_UtilConstants__c.getInstance(OPPTY_TYPE_CONVERTEDLEAD).Value__c;
            opp.Amount = myLead.Total_Weekly_Potential__c;
            //opp.Probability = Decimal.valueOf(1);

            //Updated by ADUA for SFS-1547 as 'Working' as stageName was not part of National Prospect - Sales Prcoess        
            //opp.StageName = CS_UtilConstants__c.getInstance(WORKING).Value__c;


            opp.Source__c = myLead.LeadSource;
            Database.update(opp);
            system.debug('Final StageName = ' + opp.StageName);
        } 

I need to cover the LeadRecordType.Name == 'ChefStore' and LeadRecordType.Name == 'National' part
Raj VakatiRaj Vakati
can you share the complete class ??
newbiewithapexnewbiewithapex
Complete class is big so won't let me post here