+ Start a Discussion
StaciStaci 

test class coverage for mapping

I have the below method that I don't understand how to cover in my test class.  Can anyone help please?
 
@future
    public static void createLicenseGroups()
    {

        //Query for the Account record types
        List<RecordType> rtypes = [SELECT Name, Id FROM RecordType WHERE sObjectType='License__c' AND isActive=true];
     
        //Create a map between the Record Type Name and Id for easy retrieval
        Map<String,String> LicRecTyp = new Map<String,String>{};
        for(RecordType rt: rtypes)
           LicRecTyp.put(rt.Name,rt.Id);
           
        ID gID = LicRecTyp.get('License Group');

        List<License__c> licenseGroups = new List<License__c>();
        
        Map<STRING, Schema.sObjectField> fieldsMap = Schema.SObjectType.User.fields.getMap();
        for (Schema.PicklistEntry p : fieldsMap.get('SF_License_Owner_Type__c').getDescribe().getPicklistValues())   
            licenseGroups.add(new License__c(RecordTypeID = gID, Owner_Group_Name__c = p.getLabel(), Licenses_Owned__c = 9999, Licenses_Used__c = 0));    
        
        insert licenseGroups;
}

 
Best Answer chosen by Staci
Amit Chaudhary 8Amit Chaudhary 8
Simple call above method like below

// Create all test data
CLASSNAME.createLicenseGroups();

Let us know if this will help you

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Simple call above method like below

// Create all test data
CLASSNAME.createLicenseGroups();

Let us know if this will help you
This was selected as the best answer
StaciStaci
Thanks @Amit Chaudhary 8!  That worked!