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
Rakesh Sahoo 22Rakesh Sahoo 22 

test class code coverage for apex class

Please help me to get 100% code coverage of this apex class.


public class ctrl_LeadCreation
{
    public Lead__c ld{get;set;}
    public User u{get;set;}
    public Boolean zklPr{get;set;}
    public boolean fkl{get;set;}
    public Integer x{get;set;}
    public Integer y{get;set;}
    
    public ctrl_LeadCreation(Apexpages.standardController std)
    {
        ld=(Lead__c)std.getRecord();
        u=[Select CompanyName from User where id=:Userinfo.getUserId()];
        if(u.CompanyName=='ZKL' || u.CompanyName=='PR')
        {
            zklPr=true;
        }
        if(u.CompanyName=='FKL')
        {
            fkl=true;
        }        
    }
    
    public PageReference save()
    {
        Recordtype r1=[Select id from Recordtype where sobjecttype='Lead__c' and developername=:'Lead_Eligibility_Test'];
        Recordtype r2=[Select id from Recordtype where sobjecttype='Lead__c' and developername=:'Details_For_FKL'];
        
        y=0;
        
        if(u.CompanyName=='ZKL' || u.CompanyName=='PR')
        {
            
            
            x=1;
            List<Lead__c> ldzklpr=[Select number_count__c from Lead__c where FormulateUsersCompany__c=:u.CompanyName and recordtype.developername='Lead_Eligibility_Test' order by createddate desc limit 1];
            ld.recordtypeId=r1.id;
            if(!ldzklpr.isEmpty())
            {
                y=x+Integer.valueOF(ldzklpr[0].number_count__c);
                ld.Lead_Number_Set__c=u.CompanyName+'-LD-'+y;
                ld.number_count__c=Decimal.valueOF(y);
                ld.Approval_Status__c='New';
            }
            else
            {
                ld.Lead_Number_Set__c=u.CompanyName+'-LD-'+x;
                ld.number_count__c=Decimal.valueOF(x);
                ld.Approval_Status__c='New';
            }
         }
         
         if(u.CompanyName=='FKL')
         {
             x=1;
             List<Lead__c> ldfkl=[Select number_count__c from Lead__c where FormulateUsersCompany__c=:u.CompanyName and recordtype.developername='Details_For_FKL' order by createddate desc limit 1];
             ld.recordtypeId=r2.id;
             if(!ldfkl.isEmpty())
            {
                y=x+Integer.valueOf(ldfkl[0].number_count__c);
                ld.Lead_Number_Set__c=u.CompanyName+'-LD-'+y;
                ld.number_count__c=Decimal.valueOF(y);
                ld.Approval_Status__c='New';
            }
            else
            {
                ld.Lead_Number_Set__c=u.CompanyName+'-LD-'+x;
                ld.number_count__c=Decimal.valueOF(x);
                ld.Approval_Status__c='New';
            }
         }
         
         insert ld;
         
         Pagereference pg=new PageReference('/'+ld.id);
         return pg.setRedirect(true);
    }
    
    public PageReference cancel()
    {
        Schema.DescribeSObjectResult result = Lead__c.SObjectType.getDescribe();
        PageReference pg=new PageReference('/' + result.getKeyPrefix() + '/o');
        pg.setRedirect(true);
        return pg;
   }
}


Please HELP...
Thanks
jennifer sreejennifer sree
It’s very simple to find out any matter on web as compared to textbooks, as I found this piece of writing at this website.
xender for pc (https://xenderforpcis.com" target="_blank) , Shareit (https://shareitpc.one" target="_blank), Shareit  for pc (https://shareitpcis.com" target="_blank), techfranks (https://techfranks.com" target="_blank), http://www.softwarelearnings.com/ (http://www.softwarelearnings.com/" style="color:blue; text-decoration:underline)