You need to sign in to do that
Don't have an account?

Create Test Class for Process Plugin
Hi,
I created an APEX class that creates a Flow plug-in. I followed the documentation online, I'll post link below. But I cant seem to be able to write a test class that will fully cover the APEX class.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_plugin.htm
CLASS
TEST
Im not sure how to test the describe function in the APEX code. Any information is a helpful.
Thanks,
-Julio Hernandez
I created an APEX class that creates a Flow plug-in. I followed the documentation online, I'll post link below. But I cant seem to be able to write a test class that will fully cover the APEX class.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_plugin.htm
CLASS
global class flowTask implements Process.Plugin{ global Process.PluginResult invoke(Process.PluginRequest request){ string taskCase = (String) request.inputParameters.get('CaseId'); date taskDate = date.today(); String description = (String) request.inputParameters.get('subject'); Task myTask = new Task(); myTask.ActivityDate = taskDate; myTask.Description = description; myTask.Status = 'Completed'; myTask.WhatId = taskCase; insert myTask; Map<String, Object> result = new Map<String, Object>(); return new Process.PluginResult(result); } global Process.PluginDescribeResult describe(){ Process.PluginDescribeResult result = new Process.PluginDescribeResult(); result.Name = 'flowtaskpluggin'; result.Tag = 'task'; result.inputParameters = new List<Process.PluginDescribeResult.inputParameter>{ new Process.PluginDescribeResult.InputParameter('subject', Process.PluginDescribeResult.ParameterType.STRING, true), new Process.PluginDescribeResult.InputParameter('CaseId', Process.PluginDescribeResult.ParameterType.STRING, true) }; result.outputParameters = new List<Process.PluginDescribeResult.outputParameter>{ }; return result; } }
TEST
@isTest private class flowTaskTest{ static testmethod void flowTaskTest(){ flowTask plugin = new flowTask(); Map<String, Object> inputParams = new Map<String, Object>(); string taskNum = '50063000003AEik'; //50063000003AEik-SBX | 500o000000GCryb-PROD string taskSub = 'Test Class'; inputParams.put('subject', taskSub); inputParams.put('CaseId', taskNum); Process.PluginRequest request = new Process.PluginRequest(inputParams); plugin.invoke(request); } }
Im not sure how to test the describe function in the APEX code. Any information is a helpful.
Thanks,
-Julio Hernandez
Below test class should help your test coverage. Ensure you populate all the required case fields in createCase method.
Mark this as best answer if this helps.
All Answers
Below test class should help your test coverage. Ensure you populate all the required case fields in createCase method.
Mark this as best answer if this helps.
This line seems to cover it.
Process.PluginDescribeResult result = plugin.describe();