• Hemanth Neelapu
  • NEWBIE
  • 25 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hi all! Can anyone help me to acheive Test class to 75% for the following Apex class controller. Currently i'm getting 25% coverage.
Apex Controllers-
----------------------------------
public class CLM_Agreement_Info_Controller {
    Public CLM_Request__c Request    {Set;get;}
    Public Id Req_id                    {set;get;}
    Public Id CurrentLoggedinUserId {set;get;}
    Public string type    {set;get;}
    Public Boolean display_Hco_related    {set;get;}
    Public Integer Provider_count    {set;get;}
    
    Public CLM_Agreement_Info_Controller(){
        CurrentLoggedinUserId=UserInfo.getUserId();
        Req_id=ApexPages.currentPage().getParameters().get('Req_Id');
        type=ApexPages.currentPage().getParameters().get('type');
        Provider_count=[select count() from CLM_Provider__c where CLM_Request__c =:Req_id];
        Request=[select id,CLM_Agreement_Category__c,CLM_Payment_Term__c,CLM_Abbott_Signer_Name__c,CLM_Adding_Hcp_s_to_Entity__c,CLM_MSA_Agreement__c,CLM_Authorization_For_Videotape__c,CLM_Agreement_Type__c,CLM_Page_Status__c,CLM_Agreement_Effective_Date__c,CLM_Agreement_Expiration_Date__c,CLM_Party_Type__c from CLM_Request__c where id =:Req_id];  
        Request.CLM_Agreement_Category__c='HCP Consulting';
        if((Request.CLM_Agreement_Effective_Date__c == null) &&  (Request.CLM_Agreement_Type__c =='MSA')){
            Request.CLM_Agreement_Effective_Date__c=System.today();
            Request.CLM_Agreement_Expiration_Date__c = Request.CLM_Agreement_Effective_Date__c.addYears(3);
            //Default_Exp_date();
        }else if((Request.CLM_Agreement_Effective_Date__c == null) &&  (Request.CLM_Agreement_Type__c =='SOW')){
            Request.CLM_Agreement_Effective_Date__c=System.today();
            Request.CLM_Agreement_Expiration_Date__c = Request.CLM_Agreement_Effective_Date__c.addYears(1);
            //Default_Exp_date();
        }
    }
    Public Void Default_Exp_date(){
        if((Request.CLM_Agreement_Effective_Date__c != null) &&  (Request.CLM_Agreement_Type__c =='MSA')){
            Request.CLM_Agreement_Expiration_Date__c = Request.CLM_Agreement_Effective_Date__c.addYears(3);
        }else if((Request.CLM_Agreement_Effective_Date__c != null) &&  (Request.CLM_Agreement_Type__c =='SOW')){
            Request.CLM_Agreement_Expiration_Date__c = Request.CLM_Agreement_Effective_Date__c.addYears(1);
        }
    }
    Public void save(){
        Default_Exp_date();
        if(Request.CLM_Page_Status__c =='P2'){
            //Request.CLM_Page_Status__c='P3';
            Update Request;
        }else{
            Update Request;
        }
    }
    Public Pagereference Next(){
        Default_Exp_date();
        Pagereference Page_Ref;
        if(Request.CLM_Agreement_Type__c =='SOW'){
            Page_Ref=new Pagereference('/apex/CLM_Provider_Selection_SOW?Req_Id='+Req_id+'&type='+type);            
        }else if (Request.CLM_Agreement_Type__c =='MSA'){
            Page_Ref=new Pagereference('/apex/CLM_Provider_Selection?Req_Id='+Req_id+'&type='+type);
        }
        if(Request.CLM_Page_Status__c =='P2'){
            Request.CLM_Page_Status__c='P3';
            Update Request;
        }else{
            Update Request;
        }
        return Page_Ref;
        
        /*if(Provider_count !=0){
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, 'You have already selected a provider, change Party Type will require you to select a Provider again.');
ApexPages.addMessage(msg);
return null;
}else{
if(Request.CLM_Page_Status__c =='P2'){
Request.CLM_Page_Status__c='P3';
Update Request;
}else{
Update Request;

}  
P=new Pagereference('/apex/CLM_Provider_Selection?Req_Id='+Req_id+'&type='+type);

}*/
        
        
    }
    Public Pagereference Previous(){
        //Update Request;
        Pagereference P=new Pagereference('/apex/CLM_Basic_Information?Id='+Req_id);
        return p;
    }
    Public Pagereference Cancel(){
        Pagereference P =new Pagereference('/a1h/o');
        return P;
    }
    Public Pagereference Basic_Information(){
        Update Request;
        Pagereference P =new Pagereference('/apex/CLM_Basic_Information?Id='+Req_id);
        return P;
    }
    Public Pagereference Provider_Selection(){
        Update Request;
        Pagereference P=new Pagereference(''+Req_id);
        return p;
    }
    Public Pagereference Review_and_Submit(){
        Update Request;
        Pagereference P=new Pagereference(''+Req_id);
        return p;
    }
}


Test Class-
----------------------------
@isTest
public class Test_CLM_Agreement_Info_Controller {

    /**
    *   @Description : Create test records.
    */
    @TestSetup
    Public static void createTestData() {
        
        //Create CLM_Request__c record
       CLM_Request__c request = new CLM_Request__c(CLM_Requester__c = UserInfo.getUserId(), CLM_Page_Status__c = 'P1');
             INSERT request;  
       
    }
    
    
    /**
    *   @Description : Test the functionality of CLM_Agreement_Info_Controller class and its methods.
    */
    public static testmethod void testCLM_Agreement_Info_Controller(){
        
        //Fetch CLM_Request__c record
        CLM_Request__c request = [SELECT Id,CLM_Page_Status__c,CLM_Agreement_Type__c,CLM_Agreement_Category__c,CLM_Payment_Term__c,CLM_Abbott_Signer_Name__c,CLM_Agreement_Effective_Date__c,CLM_Agreement_Expiration_Date__c,CLM_Party_Type__c FROM CLM_Request__c LIMIT 1];
             request.CLM_Agreement_Category__c = 'HCP Consulting';
                               
    
    Test.startTest();
        
        // Set pageReference of 'CLM_Agreement_Information' vf page
        PageReference pageReference = Page.CLM_Agreement_Information; // Add VF page name here
        Test.setCurrentPage(pageReference);
        
        // Put 'Id' parameter
        ApexPages.currentPage().getParameters().put('Id', request.Id);
        
        // Create Object of 'CLM_Agreement_Info_Controller' class and call its method to testing the functionality of it.
        ApexPages.StandardController standerdControllerObj = new ApexPages.StandardController(request);
        CLM_Agreement_Info_Controller newObject = new CLM_Agreement_Info_Controller();
        
        newObject.Default_Exp_date();
        newObject.Save();
        newObject.Next();
        newObject.Previous();
        newObject.Cancel();
        newObject.Basic_Information();
        newObject.Provider_Selection();
        newObject.Review_and_Submit();
        
        Test.stopTest();
    
    
}
}
Hi Guys,
I need help in writing a test class for the below Apex Schedulable batch Process.
Can anyone help me out?

global class CLM_Batch_ExpireAgreements implements Database.Batchable<sObject>,Schedulable,Database.Stateful {

    //Batch Start method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        string Agreement_Status = 'Activated' ;
        string strQuery='SELECT id,Apttus__Contract_End_Date__c , Apttus__Status__c , Apttus__Auto_Renewal__c ,Apttus__Status_Category__c FROM Apttus__APTS_Agreement__c';    
         strQuery+=' WHERE Apttus__Status__c = \'Activated\' and Apttus__Contract_End_Date__c < today and Apttus__Auto_Renewal__c = False' ;    
            system.debug('  febgdg'+ strQuery);
        return Database.getQueryLocator(strQuery);
    }
    
   //Batch Execute method 
    global void execute(Database.BatchableContext BC, List<Apttus__APTS_Agreement__c> Scope) {
        
        list<Apttus__APTS_Agreement__c> agr = new list<Apttus__APTS_Agreement__c>();
        for(Apttus__APTS_Agreement__c agrObj : scope){
          
           agrObj.Apttus__Status__c ='Expired' ;
           agrObj.Apttus__Status_Category__c ='Expired' ;
            agr.add(agrObj);            
        }
       update agr;
    }
    
     //Batch Finish method    
     global void finish(Database.BatchableContext BC) { 
             
    }
    
   //Method which schedules the batch
       global void execute(SchedulableContext sc) {        
      CLM_Batch_ExpireAgreements snInstance = new CLM_Batch_ExpireAgreements ();
       ID batchprocessid = Database.executeBatch(snInstance);
    } 
    
}
Hi Guys,
 
I have a requirement which i need to acheive it by using Process Builder.
 
Whenever Agreement is fully signed by using Docusign, then that Agreement has to be Activate Automatically.

Can anyone suggest how to acheive ?
Hi Guys,
I have a requirement....

How to create a Apex Job to process a file and update status on the record..?
Write a webservice that takes in a file and then process it....?
I need to send a email notification on daily basis based on the 2 custom fields. Can i acheive by using workflow Rules?

Can Anyone suggest me a good solution to perform the requirement.

Thanks in advance
I need to send a email notification on daily basis based on the 2 custom fields. Can i acheive by using workflow Rules?

Can Anyone suggest me a good solution to perform the requirement.

Thanks in advance
can somebody help me how to write test class for below class

global class WizardCallBack_CLM implements Apttus.WizardCustomClass.IDataSourceCallback{
      
      /*
        Description :- Accepts Account Id,Record Type Id,Parent Id and Account Name to autopopulate as parameter and sends the JSON response to be used in Wizard
        Input :- Wizard ID, Map of parameters passed in URL
        Output :- JSON response using class WizardCallbackResponse_CLM
      */
      global String getData(String wizardId,Map<String,String> inputParameters){
          String accountId=inputParameters.get('accountId');
          String recordTypeId = inputParameters.get('recordTypeId');
          String accountName=inputParameters.get('accountName');
          String parentId = inputParameters.get('parentId');
          String oemNames = inputParameters.get('oemNames').replace(';,',';');
          System.debug('>>>>>>>> accountName '+accountName);
          System.debug('>>>>>>>> parentId '+parentId);
          
          WizardCallbackResponse_CLM.WizardCallbackData data = new WizardCallbackResponse_CLM.WizardCallbackData();
          
          List<Apttus__WizardInputControl2__c> inputControlsList = [SELECT Apttus__Question__c,Apttus__WizardStepId__c FROM Apttus__WizardInputControl2__c where Apttus__WizardStepId__c in (SELECT id FROM Apttus__WizardStep2__c where Apttus__WizardDesignId__c =: Label.CPG)];
          
          List<WizardCallbackResponse_CLM.UserResponses> userResponseList= new List<WizardCallbackResponse_CLM.UserResponses>();
          System.debug('>>>>>>>>List'+inputControlsList);
          for(Apttus__WizardInputControl2__c inputObj :inputControlsList){
             System.debug('>>>>>>>>question'+inputObj.Apttus__Question__c);
             if(accountName!=null && inputObj.Apttus__Question__c == 'What is the legal name of the dealer?')
             {
                 System.debug('>>>>>>Inside If');
                 WizardCallbackResponse_CLM.UserResponses userResponse = new WizardCallbackResponse_CLM.UserResponses();
                 userResponse.Question = 'What is the company name?';
                 userResponse.inputRepeatSequence = 0;
                 userResponse.inputControlId = inputObj.id;
                 userResponse.Answer=accountName;
                 userResponseList.add(userResponse);
             }
             
             }
          }
                          
                  
          data.UserResponses = userResponseList;
          data.Parameters = null;    
          return JSON.serialize(data);
    }   
}
 
  • November 06, 2018
  • Like
  • 0