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
bharath kuamarbharath kuamar 

Apex test class

Hi,

 

 can anyone help me writing test class for the below class

 

global class PDFGencontroller{
String LongDate = ' ';
String hostUrl;
String PreferId=System.currentPagereference().getParameters().get('id'); 
public PDFGencontroller()
{
 hostUrl = 'https://'+ ApexPages.currentPage().getHeaders().get('Host') +'/servlet/servlet.FileDownload?file=';
  }

public list<contact> getcontactinfo(){
   
    system.debug('<<<<<<<<<<<<<Inside getContactInfo>>>>>>>>>>>>>>'+PreferId);
    List<Contact> con = new List<Contact>();
    Preference__c  p=[select opportunity__c from preference__c where id=:PreferId];
    OpportunityContactRole oRole = [Select ContactId from OpportunityContactRole Where OpportunityId=:p.opportunity__c ];
    con =[select firstname,lastname,Birthdate,Email,Phone from contact where id=:oRole.ContactId];
    return con;
    
}

 public list<Preference__c> getPreferenceInfo(){
   
    List<Preference__c> con1 = new List<Preference__c>();
    con1=[select name,Payment_Modes__c,payment_frequency__c,duration__c  from preference__c where id=:PreferId];
    return con1;
   }
   
   public list<commitment__c> getCommitmentInfo(){
    
    
    List<commitment__c> con2 = new List<commitment__c>();
    con2=[select name,Commitment_Type__c,Start_Date__c,End_Date__c,status__c from commitment__c where preference__c=:PreferId];
    return con2;
    
   }
   
 public list<Payment_Schedule__c> getPaymentInfo(){
    
    
    List<Payment_Schedule__c> con3 = new List<Payment_Schedule__c>();
    Preference__c p=[select opportunity__c from preference__c where id=:PreferId];
    con3=[select name,Payment_Start_Date__c,Payment_End_Date__c,Payment_Frequency__c,Payment_Mode__c,Amount__c  from Payment_Schedule__c where Opportunity__c =:p.opportunity__c ];
    
    return con3;
   }
   
    public String getLongDate() {
        Datetime cDT = System.now();
        LongDate = cDT.format('MMMM d,yyyy');
        return LongDate;
      }