You need to sign in to do that
Don't have an account?
SFDC Panther 92
Hi,
I have created a Class for einstein bot and since only one invocable method can be created in a class , i have created a service class and passed the parameter from my controller class. Both the class are working fine and while creating a test class i am able to cover the code coverage of 90% for my service class . But i am facing issue for the controller class.
Controller class
public class GlobalWebChatBotController {
/* Input Wrapper Class for Values to be passed from Einstein Bot */
public class ControllerInput {
@InvocableVariable
public String fctgBrandName;
@InvocableVariable
public String operationTypeString;
@InvocableVariable
public String chatTranscriptRecordId;
@InvocableVariable
public String enquiry;
@InvocableVariable
public String companyName;
@InvocableVariable
public LiveChatTranscript chatTranscriptRecord;
@InvocableVariable
public String countryName;
@InvocableVariable
public String phoneNumber;
@InvocableVariable
public String contactPreference;
@InvocableVariable
public String feedbackcomment;
@InvocableVariable
public String isfeedback;
@InvocableVariable
public String selectedKnowledgeCategory;
@InvocableVariable
public String selectedKnowledgeSubCategory;
@InvocableVariable
public String selectedTitle;
@InvocableVariable
public sObject selectedKnowledgeArticle;
}
/* Output Wrapper Class for Values to be passed to Einstein Bot */
public class ControllerOutput {
@InvocableVariable
public LiveChatTranscript chatTranscriptRecord;
@InvocableVariable
public String visitorCustomerType;
@InvocableVariable
public String supplierPublicDocumentLink;
@InvocableVariable
public Case loggedCaseRecord;
@InvocableVariable
public Contact linkedContactRecord;
@InvocableVariable
public String companyName;
@InvocableVariable
public String FirstName;
@InvocableVariable
public String LastName;
@InvocableVariable
public List<String> knowledgeCategories;
@InvocableVariable
public List<String> knowledgeSubCategories;
@InvocableVariable
public List<sObject> knowledgeArticle;
}
/* Invocable Method of Controller to be called From Einstein Bot*/
@InvocableMethod(label='')
public static List<ControllerOutput> botControllerMethod(list<ControllerInput> controllerInputs){
GlobalWebChatBotServiceClass serviceClassObject=new GlobalWebChatBotServiceClass();
ControllerInput inputVariable=controllerInputs[0];
ControllerOutput outputVariable= new ControllerOutput();
"
"
}
Service class
public without sharing class GlobalWebChatBotServiceClass {
public LiveChatTranscript returnChatTranscriptRecord(Id chatTranscriptRecordId) {
List<LiveChatTranscript> chatTranscriptRecords=[SELECT Id,Visitor_Customer_Type__c,Visitor_Email__c,
Visitor_First_Name__c,Visitor_Last_Name__c,Visitor_Company__c,ContactId,Location FROM LiveChatTranscript
Where Id = :chatTranscriptRecordId];
if(chatTranscriptRecords.size()>0) {
return chatTranscriptRecords[0];
} else {
return null;
}
}
Test Class
@isTest
public class GlobalWebChatBotTestClass {
@istest
static void chattranscripttest(){
LiveChatTranscript chat = new LiveChatTranscript (Visitor_Customer_Type__c = 'Supplier' , Visitor_Email__c = 'a@a.com' ,
Visitor_First_Name__c = 'testa' ,Visitor_Last_Name__c = 'testb' , livechatvisitorid = '5717Z000001LxeQQAS',
Visitor_Company__c = 'test',Location = 'test');
insert chat;
GlobalWebChatBotServiceClass livechat = new GlobalWebChatBotServiceClass();
Test.startTest();
LiveChatTranscript lct= livechat.returnChatTranscriptRecord(chat.Id);
GlobalWebChatBotController.botControllerMethod( i dont know which parameter i should pass here);
Test.StopTest();
}
I dont know how to pass controller input parameter , can anyone help me with it
how to pass wrapper class as parameter in test class
Hi,
I have created a Class for einstein bot and since only one invocable method can be created in a class , i have created a service class and passed the parameter from my controller class. Both the class are working fine and while creating a test class i am able to cover the code coverage of 90% for my service class . But i am facing issue for the controller class.
Controller class
public class GlobalWebChatBotController {
/* Input Wrapper Class for Values to be passed from Einstein Bot */
public class ControllerInput {
@InvocableVariable
public String fctgBrandName;
@InvocableVariable
public String operationTypeString;
@InvocableVariable
public String chatTranscriptRecordId;
@InvocableVariable
public String enquiry;
@InvocableVariable
public String companyName;
@InvocableVariable
public LiveChatTranscript chatTranscriptRecord;
@InvocableVariable
public String countryName;
@InvocableVariable
public String phoneNumber;
@InvocableVariable
public String contactPreference;
@InvocableVariable
public String feedbackcomment;
@InvocableVariable
public String isfeedback;
@InvocableVariable
public String selectedKnowledgeCategory;
@InvocableVariable
public String selectedKnowledgeSubCategory;
@InvocableVariable
public String selectedTitle;
@InvocableVariable
public sObject selectedKnowledgeArticle;
}
/* Output Wrapper Class for Values to be passed to Einstein Bot */
public class ControllerOutput {
@InvocableVariable
public LiveChatTranscript chatTranscriptRecord;
@InvocableVariable
public String visitorCustomerType;
@InvocableVariable
public String supplierPublicDocumentLink;
@InvocableVariable
public Case loggedCaseRecord;
@InvocableVariable
public Contact linkedContactRecord;
@InvocableVariable
public String companyName;
@InvocableVariable
public String FirstName;
@InvocableVariable
public String LastName;
@InvocableVariable
public List<String> knowledgeCategories;
@InvocableVariable
public List<String> knowledgeSubCategories;
@InvocableVariable
public List<sObject> knowledgeArticle;
}
/* Invocable Method of Controller to be called From Einstein Bot*/
@InvocableMethod(label='')
public static List<ControllerOutput> botControllerMethod(list<ControllerInput> controllerInputs){
GlobalWebChatBotServiceClass serviceClassObject=new GlobalWebChatBotServiceClass();
ControllerInput inputVariable=controllerInputs[0];
ControllerOutput outputVariable= new ControllerOutput();
"
"
}
Service class
public without sharing class GlobalWebChatBotServiceClass {
public LiveChatTranscript returnChatTranscriptRecord(Id chatTranscriptRecordId) {
List<LiveChatTranscript> chatTranscriptRecords=[SELECT Id,Visitor_Customer_Type__c,Visitor_Email__c,
Visitor_First_Name__c,Visitor_Last_Name__c,Visitor_Company__c,ContactId,Location FROM LiveChatTranscript
Where Id = :chatTranscriptRecordId];
if(chatTranscriptRecords.size()>0) {
return chatTranscriptRecords[0];
} else {
return null;
}
}
Test Class
@isTest
public class GlobalWebChatBotTestClass {
@istest
static void chattranscripttest(){
LiveChatTranscript chat = new LiveChatTranscript (Visitor_Customer_Type__c = 'Supplier' , Visitor_Email__c = 'a@a.com' ,
Visitor_First_Name__c = 'testa' ,Visitor_Last_Name__c = 'testb' , livechatvisitorid = '5717Z000001LxeQQAS',
Visitor_Company__c = 'test',Location = 'test');
insert chat;
GlobalWebChatBotServiceClass livechat = new GlobalWebChatBotServiceClass();
Test.startTest();
LiveChatTranscript lct= livechat.returnChatTranscriptRecord(chat.Id);
GlobalWebChatBotController.botControllerMethod( i dont know which parameter i should pass here);
Test.StopTest();
}
I dont know how to pass controller input parameter , can anyone help me with it
Try with following if this resolves your issue, please can you mark this as best answer.
All Answers
kindly find the solution
Test Class If you find your Solution then mark it as the best answer.
Thanks and Regards
Suraj Tripathi.
I am still getting the same error , i.e. Method does not exist or incorrect signature: void botControllerMethod(GlobalWebChatBotController.ControllerInput) from the type GlobalWebChatBotController
Try with following if this resolves your issue, please can you mark this as best answer.
Thanks a lot.. it worked