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
Wajeed KhanWajeed Khan 

Can any body help me to write the test class for this

public class optSigntureCopyController  {
    public id AccountID{
        get;
        set;
        
    }
    public list<OCE__Opt__c> Opts{get;set;}
    public list<OCE__OptDetail__c> Optdetails{get;set;}
    public set<string> Optids; 
    public WrapperClass InnerClass {get;set;}
    Public Account AccountRec {get;set;}
    public list<OCE__AccountAddress__c> Accountaddress{get;set;}
    public list<OCE__Affiliation__c> affs {get;set;}
    
    
    Public WrapperClass  getactualDetails(){
        system.debug('AccountID in controller '+AccountID);
        AccountRec = new Account();
        InnerClass = new WrapperClass();
        Opts = new list<OCE__Opt__c>();
        Optdetails = new list<OCE__OptDetail__c>();
        Optids = new set<string>();
        Accountaddress = new list<OCE__AccountAddress__c>();
        set<id> OptSig = new set<id>();
        
        
        if(AccountID!=null){
            AccountRec = [select id,lastname,firstname,PersonBirthdate,GI_Phone_Number__c,GI_Fiscal_Code__c,OCE__ProfessionalTitle__c,toLabel(OCE__Specialty__c) from account where id =: AccountID];
            Accountaddress = [select  OCE__Account__c, OCE__AddressLine1__c, OCE__City__c, GI_State__c, OCE__ZipCode__c from OCE__AccountAddress__c where OCE__IsPrimary__c = true and OCE__Account__c =:AccountID];
            if(Accountaddress.size()==0){
                Accountaddress = [select  OCE__Account__c, OCE__AddressLine1__c, OCE__City__c, GI_State__c, OCE__ZipCode__c from OCE__AccountAddress__c where  OCE__Account__c =:AccountID];
            }
            affs = [SELECT Id, OCE__To__c, OCE__From__r.Phone FROM OCE__Affiliation__c WHERE OCE__IsPrimary__c = true AND OCE__To__c = : AccountID];
            InnerClass.Accountlastname = AccountRec.lastname;
            InnerClass.AccountFirstName = AccountRec.firstname;
            InnerClass.AccountBirthdate = AccountRec.PersonBirthdate;
            InnerClass.Addressline1 = Accountaddress[0].OCE__AddressLine1__c;
            InnerClass.ficalcode = AccountRec.GI_Fiscal_Code__c;
            InnerClass.city = Accountaddress[0].OCE__City__c;
            InnerClass.state = Accountaddress[0].GI_State__c;
            InnerClass.Zip = Accountaddress[0].OCE__ZipCode__c;
            //InnerClass.PhoneNo = affs[0].OCE__From__r.Phone;
            InnerClass.PhoneNo = AccountRec.GI_Phone_Number__c;
            InnerClass.professiontitle = AccountRec.OCE__ProfessionalTitle__c;
            InnerClass.speciality = AccountRec.OCE__Specialty__c;
            
            Opts = [select id,oce__account__c,OCE__Signature__c from OCE__Opt__c where oce__account__c =: AccountID and OCE__Active__c = true];
            system.debug('Opts innn'+Opts);
            if(Opts.size()>0){
                for(OCE__Opt__c Opt : Opts){
                    Optids.add(Opt.id);
                    if(Opt.OCE__Signature__c!=null){
                        OptSig.add(Opt.id);
                    }
                }
            list<Attachment> sigAttachmentList = [SELECT Id FROM Attachment WHERE  parentid IN : OptSig];
            if(sigAttachmentList.size()>0){
                InnerClass.signatureid  = sigAttachmentList[0].id;
            }
            
            Optdetails =  [SELECT Id, OCE__Topic__c, GI_Opt_Flag__c,  OCE__Subscription__c, OCE__Channel__c, OCE__ChannelValue__c, OCE__OfflineCreatedDate__c, OCE__Opt__c,createdby.name,OCE__Topic__r.name FROM OCE__OptDetail__c WHERE OCE__Opt__c In : Optids];
            InnerClass.Optdate = Optdetails[0].OCE__OfflineCreatedDate__c.date();
            InnerClass.userName = Optdetails[0].createdby.name;
            if(Optdetails[0].OCE__ChannelValue__c!=''){
                InnerClass.emailvalue =  Optdetails[0].OCE__ChannelValue__c;
            }
            
            if(Optdetails.size()>0){
                for(OCE__OptDetail__c OptDetail : Optdetails){
                    if(OptDetail.OCE__Topic__r.name == Label.Opt_Topic_1 ){
                        InnerClass.topic1 = topicOpted(OptDetail);
                    }
                    if(OptDetail.OCE__Topic__r.name == Label.Opt_Topic_2){
                        InnerClass.topic2 = topicOpted(OptDetail);
                    }
                    if(OptDetail.OCE__Topic__r.name ==Label.Opt_Topic_3){
                        InnerClass.topic3 = topicOpted(OptDetail);
                    }
                        
                }
            }
                
            }
            system.debug('Wrapper values final '+InnerClass);
        }
        return InnerClass;
    }
    
    
     
     
    public  string topicOpted(OCE__OptDetail__c optDetail){
        string istopicOpted;
        if(optDetail.OCE__Subscription__c == 'Opt In')
            istopicOpted = 'SI';
        else if(optDetail.OCE__Subscription__c == 'Opt Out')
            istopicOpted = 'NO';
        else if(optDetail.OCE__Subscription__c == 'Not Asked')
            istopicOpted = 'NO';
        
        return istopicOpted;
    } 
    Public class WrapperClass{
        public date Optdate{get;set;}
        public string userName {get;set;}
        Public string Accountlastname {get;set;}
        Public string AccountFirstName {get;set;}
        public date AccountBirthdate {get;set;}
        public string Addressline1 {get;set;}
        public string ficalcode {get;set;}
        public string city {get;set;}
        public string state {get;set;}
        public string Zip {get;set;}
        public string PhoneNo{get;set;}
        public string emailvalue{get;set;}
        public string professiontitle {get;set;}
        public string speciality {get;set;}
        public id signatureid {get;set;}
        public string topic1 {get;set;}
        public string topic2 {get;set;}
        public string topic3 {get;set;}
        
        
    }
    
}