You need to sign in to do that
Don't have an account?
prati@salesforce
Translation plugin Test Class
Hi folks,
I have written a translation plugin to be used by a flow and I tried to write test class for the same but I keep getting error when i run the test. Below is my class.. Please help me with this.
global class FoodSafetyCriteriaNotMetPlugin implements Process.Plugin{
global Process.PluginResult invoke(Process.PluginRequest request){
String apiName = (String)request.inputParameters.get('Criteria_Not_Met_Field_API_Name');
System.debug('Apiname ' +apiName);
Id recordId = (Id) request.inputParameters.get('QA_Id');
String queryString = 'SELECT toLabel('+apiName+') FROM Food_Safety_QA__c WHERE Id = :recordId LIMIT 1';
List<Food_Safety_QA__c> listQA = Database.query(queryString);
Food_Safety_QA__c objQA = listQA[0];
String returnString = (string)objQA.get(apiName);
System.debug('Return String is :' +returnString);
Map<String,Object> result = new Map<String,Object>();
result.put('Translated_Value', returnString);
return new Process.PluginResult(result);
}
global Process.PluginDescribeResult describe() {
Process.PluginDescribeResult result = new Process.PluginDescribeResult();
result.Name = 'Get the Translated Criteria Not Met';
result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
new Process.PluginDescribeResult.InputParameter('Criteria_Not_Met_Field_API_Name',Process.PluginDescribeResult.ParameterType.STRING,true),
new Process.PluginDescribeResult.InputParameter('QA_Id',Process.PluginDescribeResult.ParameterType.STRING,true)
};
result.outputParameters = new
List<Process.PluginDescribeResult.OutputParameter>{
new Process.PluginDescribeResult.OutputParameter('Translated_Value',Process.PluginDescribeResult.ParameterType.STRING)
};
return result;
}
}
I have written a translation plugin to be used by a flow and I tried to write test class for the same but I keep getting error when i run the test. Below is my class.. Please help me with this.
global class FoodSafetyCriteriaNotMetPlugin implements Process.Plugin{
global Process.PluginResult invoke(Process.PluginRequest request){
String apiName = (String)request.inputParameters.get('Criteria_Not_Met_Field_API_Name');
System.debug('Apiname ' +apiName);
Id recordId = (Id) request.inputParameters.get('QA_Id');
String queryString = 'SELECT toLabel('+apiName+') FROM Food_Safety_QA__c WHERE Id = :recordId LIMIT 1';
List<Food_Safety_QA__c> listQA = Database.query(queryString);
Food_Safety_QA__c objQA = listQA[0];
String returnString = (string)objQA.get(apiName);
System.debug('Return String is :' +returnString);
Map<String,Object> result = new Map<String,Object>();
result.put('Translated_Value', returnString);
return new Process.PluginResult(result);
}
global Process.PluginDescribeResult describe() {
Process.PluginDescribeResult result = new Process.PluginDescribeResult();
result.Name = 'Get the Translated Criteria Not Met';
result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
new Process.PluginDescribeResult.InputParameter('Criteria_Not_Met_Field_API_Name',Process.PluginDescribeResult.ParameterType.STRING,true),
new Process.PluginDescribeResult.InputParameter('QA_Id',Process.PluginDescribeResult.ParameterType.STRING,true)
};
result.outputParameters = new
List<Process.PluginDescribeResult.OutputParameter>{
new Process.PluginDescribeResult.OutputParameter('Translated_Value',Process.PluginDescribeResult.ParameterType.STRING)
};
return result;
}
}