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
GeetuGeetu 

Wizard test class - Need help

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);
    }   
}
 
Best Answer chosen by Geetu
Raj VakatiRaj Vakati
try this and add all required field
s
@isTest
private class WizardCallBack_CLMTest{
    
     static testMethod void myTestMethod(){       
      
		
	
       
        Test.startTest();
		
		Id recId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('DeveloperNameOfRecordType').getRecordTypeId();

		
		  Account parentAccount = new Account();
        parentAccount.Name ='Parent Account';
		parentAccount.RecordTypeId = recId ;
        insert parentAccount;
        
        // insert child Account
        Account childAccount = new Account();
        childAccount.Name ='Test Account';
				childAccount.RecordTypeId = recId ;

        childAccount.ParentId = parentAccount.Id;
        insert childAccount;
		
		Apttus__WizardInputControl2__c ins = new Apttus__WizardInputControl2__c() ;
		// add other fields 
		insert ins ;
		
		
		Apttus__WizardStep2__c  wsd = new Apttus__WizardStep2__c () ;
		insert wsd ;
		
		Map<String,String> inputParameters = new Map<String,String>() ;
		
		
		 inputParameters.put('accountId' ,parentAccount.Id);
          inputParameters.put('recordTypeId' , parentAccount.RecordTypeId);
         inputParameters.put('accountName' , parentAccount.Name);
          inputParameters.put('parentId' ,parentAccount.Id );
         inputParameters.put('oemNames', 'askdgkhasd')
		
		WizardCallBack_CLM  lcm = new WizardCallBack_CLM () ;
		lcm.getData('YOUR_WIZI_ID', inputParameters);
		
		
        Test.stopTest(); 
     }
}

 

All Answers

Raj VakatiRaj Vakati
try this and add all required field
s
@isTest
private class WizardCallBack_CLMTest{
    
     static testMethod void myTestMethod(){       
      
		
	
       
        Test.startTest();
		
		Id recId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('DeveloperNameOfRecordType').getRecordTypeId();

		
		  Account parentAccount = new Account();
        parentAccount.Name ='Parent Account';
		parentAccount.RecordTypeId = recId ;
        insert parentAccount;
        
        // insert child Account
        Account childAccount = new Account();
        childAccount.Name ='Test Account';
				childAccount.RecordTypeId = recId ;

        childAccount.ParentId = parentAccount.Id;
        insert childAccount;
		
		Apttus__WizardInputControl2__c ins = new Apttus__WizardInputControl2__c() ;
		// add other fields 
		insert ins ;
		
		
		Apttus__WizardStep2__c  wsd = new Apttus__WizardStep2__c () ;
		insert wsd ;
		
		Map<String,String> inputParameters = new Map<String,String>() ;
		
		
		 inputParameters.put('accountId' ,parentAccount.Id);
          inputParameters.put('recordTypeId' , parentAccount.RecordTypeId);
         inputParameters.put('accountName' , parentAccount.Name);
          inputParameters.put('parentId' ,parentAccount.Id );
         inputParameters.put('oemNames', 'askdgkhasd')
		
		WizardCallBack_CLM  lcm = new WizardCallBack_CLM () ;
		lcm.getData('YOUR_WIZI_ID', inputParameters);
		
		
        Test.stopTest(); 
     }
}

 
This was selected as the best answer
GeetuGeetu
Thanks Raj...this is perfect... and helped me to write test class. 
Hemanth NeelapuHemanth Neelapu
Hi Geetu,

I have a similar requirement for Apttus wizard,
can you please send the complete code involved in this requirement including classes like WizardCallbackResponse_CLM.

If possible please provide your contact details.

Thanks!