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 MhetreAkshay Mhetre 

Test class......not getting coverd ..give me solution..help please

  @AuraEnabled
    public static string getProfileCached(Id RecordId){
        Id profileId = UserInfo.getProfileId();
        String profileName =[Select Id, Name from Profile where Id=:profileId].Name;
        system.debug('Profile Name'+profileName);
        if('RCU Agent Community' == profileName){
            List<Case> caselist= [Select Id, RecordTypeId, OwnerId, Agent_Decision__c, Allocated_By__C, RCU_Sampling_Status__c
                                  From Case Where ParentId=:RecordId and RCU_Agency_Action__c <>'Accepted'];
            if(caseList != null && caseList.size()>0){
                return 'show';
            }else{
                return 'hide';
            }
        }
        return 'hide';
    }
Best Answer chosen by Akshay Mhetre
CharuDuttCharuDutt
Hii Akshay Mehtre
Try Below Test Class
@isTest
public class CaseClassTest {
@isTest
    Public static void unittest(){
        
        Profile p = [SELECT Id FROM Profile WHERE Name='RCU Agent Community'];
        User usr = new User(LastName = 'sample',
                            FirstName='sam',
                            Alias = 'simplSam',
                            Email = 'ssamsimple@asdf.com',
                            Username = 'ssamsimple@asdf.com',
                            ProfileId = p.id,
                            TimeZoneSidKey = 'GMT',
                            LanguageLocaleKey = 'en_US',
                            EmailEncodingKey = 'UTF-8',
                            LocaleSidKey = 'en_US'
                           );
        insert usr;
        system.runAs(usr){
        Case c= new Case();
        c.Status='New';
        c.Origin='Phone';
/*Fill Required Fileds*/
        c.RCU_Agency_Action__c='Other Than Accepted';
        insert c;
        
         Case c1= new Case();
        c1.Status='New';
        c1.Origin='Phone';
        c1.ParentId=c.Id;
/*Fill Required Fileds*/
        c1.RCU_Agency_Action__c='Other Than Accepted';
        insert c1;
        CaseClass.getProfileCached(c.Id);
        CaseClass.getProfileCached(c1.Id);
        }
    }
}
Please Mark It As Best Answer If It Helps
Thank You!