Newer Version Available
FunctionInvokeMock Interface
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, 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 in Functions.MockFunctionInvocationFactory.
FunctionInvokeMock Methods
The following are methods for FunctionInvokeMock.
respond(functionName, payload)
Signature
public functions.FunctionInvocation respond(String functionName, String payload)
Parameters
Return Value
Type: FunctionInvocation Interface
The result of the mock call to Salesforce Functions. Appropriate responses can be generated by using the createSuccessResponse() and createErrorResponse() methods in the Functions.MockFunctionInvocationFactory class.
FunctionInvokeMock Example Implementation
This is sample implementation of the functions.FunctionInvokeMock interface.
This example shows the minimal setup required for testing synchronous and asynchronous functions and is simplified to include both function invocations and the FunctionCallback class.