Newer Version Available
MockFunctionInvocationFactory Class
Use the MockFunctionInvocationFactory methods to generate appropriate mock responses for
testing Salesforce Functions.
Namespace
Usage
To mock Salesforce Functions testing, implement an appropriate mock response in the respond(functionName,payload) method of the FunctionInvokeMock interface. During mock testing of a Salesforce Functions, the Apex runtime sends the response specified in the respond() method, rather than invoking the function itself. Appropriate success and error messages can be configured with the createSuccessResponse(invocationId,message) and createErrorResponse(invocationId,functionsErrorType,errorMsg) methods.
MockFunctionInvocationFactory Methods
The following are methods for MockFunctionInvocationFactory.
createErrorResponse(invocationId, functionsErrorType, errMsg)
Signature
public static functions.FunctionInvocation createErrorResponse(String invocationId, functions.FunctionErrorType functionsErrorType, String errMsg)
Parameters
- invocationId
- Type: String
- The ID associated with a call to either the synchronous or asynchronous Function.invoke() method.
- functionsErrorType
- Type: FunctionErrorType Enum
- The error type of FunctionInvocationError.
- errMsg
- Type: String
- The error message.