API_OutboundTestHelper
Class · Group: Testing
global inherited sharing class API_OutboundTestHelperClass has base methods that can be used to test an outbound service.
Since: 1.0
Example:
API_OutboundTestHelper.assertCallSuccessful(SERVICE_NAME, record.Id, parameters);Methods
| Method | Description |
|---|---|
| global static void assertCallAborted(ApiCall__c apiCall, String exceptionMessage) | Tests that an API call aborts with a specific error message. |
| global static List assertCallAborted(List<ApiCall__c> apiCalls) | Tests that a web service call is aborted as expected. |
| global static void assertCallAborted(List<ApiCall__c> apiCalls, String exceptionMessage) | Tests that an API call aborts with a specific error message. |
| global static API_Base assertCallAborted(String serviceName, Id recordId) | Tests that a web service call is aborted as expected. |
| global static API_Base assertCallAborted(String serviceName, String, String> parameters) | Tests that an API call aborts as expected with parameters. |
| global static API_Base assertCallAborted(String serviceName, String> parameterNames) | Tests an aborted API call with parameter names. |
| global static API_Base assertCallAborted(String serviceName, String parameterName) | Tests an aborted API call with a single parameter name. |
| global static List assertCallFailed(List<ApiCall__c> apiCalls) | Tests that a web service call fails as expected. |
| global static List assertCallSuccessful(List<ApiCall__c> apiCalls) | Tests that a web service call is executed successfully for each of the provided API calls. |
| global static API_Base assertCallSuccessful(String serviceName, Id recordId) | Tests the successful execution of a web service call. |
| global static API_Base assertCallSuccessful(String serviceName, String, String> parameters) | Tests the successful execution of a web service call, passing a map of parameters. |
| global static API_Base assertCallSuccessful(String serviceName, String> parameterNames) | Tests the successful execution of a web service call, passing a set of parameters. |
| global static API_Base assertCallSuccessful(String serviceName, String parameterName) | Tests the successful execution of a web service call, passing a single parameter. |
| global static List assertParseFailed(List<ApiCall__c> apiCalls) | Tests that a web service call fails to parse the response. |
Method Details
assertCallAborted
global static void assertCallAborted(ApiCall__c apiCall, String exceptionMessage)Tests that an API call aborts with a specific error message.
Parameters:
apiCall(ApiCall__c) - The API call containing the service and parameters to callexceptionMessage(String) - The error message that must exist in the response
Since: 1.0
Example:
ApiCall__c apiCall = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
API_OutboundTestHelper.assertCallAborted(apiCall, 'Expected error message');assertCallAborted
global static List<API_Base> assertCallAborted(List<ApiCall__c> apiCalls)Tests that a web service call is aborted as expected.
Parameters:
apiCalls(List) - The API calls containing the services and parameters to call
Returns: API_Base - A list of handlers that processed the requests.
Since: 1.0
Example:
List<ApiCall__c> apiCalls = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
List<API_Base> handlers = API_OutboundTestHelper.assertCallAborted(apiCalls);assertCallAborted
global static void assertCallAborted(List<ApiCall__c> apiCalls, String exceptionMessage)Tests that an API call aborts with a specific error message.
Parameters:
apiCalls(List) - The API calls containing the services and parameters to callexceptionMessage(ApiCall__c) - The message string which is checked in the abort message
Since: 1.0
Example:
List<ApiCall__c> apiCalls = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
API_OutboundTestHelper.assertCallAborted(apiCalls, 'Expected error message');assertCallAborted
global static API_Base assertCallAborted(String serviceName, Id recordId)Tests that a web service call is aborted as expected.
Parameters:
serviceName(String) - The class name of the API handlerrecordId(Id) - The object that triggered the callout (optional)
Returns: API_Base - The handler executing the web service call.
Since: 1.0
Example:
API_Base handler = API_OutboundTestHelper.assertCallAborted(SERVICE_NAME, record.Id);assertCallAborted
global static API_Base assertCallAborted(String serviceName, Id recordId, Map<String, String> parameters)Tests that an API call aborts as expected with parameters.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameters(Map) - Map of parameters to pass to the API call
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
Map<String, String> parameters = new Map<String, String>{API_MyService.PARAM_KEY => 'value'};
API_Base handler = API_OutboundTestHelper.assertCallAborted(SERVICE_NAME, record.Id, parameters);assertCallAborted
global static API_Base assertCallAborted(String serviceName, Id recordId, Set<String> parameterNames)Tests an aborted API call with parameter names.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameterNames(Set) - Names of parameters to pass to the service handler
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
Set<String> parameterNames = new Set<String>{'param1', 'param2'};
API_Base handler = API_OutboundTestHelper.assertCallAborted(SERVICE_NAME, record.Id, parameterNames);assertCallAborted
global static API_Base assertCallAborted(String serviceName, Id recordId, String parameterName)Tests an aborted API call with a single parameter name.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameterName(String) - Name of a parameter to pass to the service handler
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
API_Base handler = API_OutboundTestHelper.assertCallAborted(SERVICE_NAME, record.Id, API_MyService.PARAM_KEY);assertCallFailed
global static List<API_Base> assertCallFailed(List<ApiCall__c> apiCalls)Tests that a web service call fails as expected.
Parameters:
apiCalls(List) - The API calls containing the services and parameters to call
Returns: API_Base - A list of handlers that processed the request
Since: 1.0
Example:
List<ApiCall__c> apiCalls = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
List<API_Base> handlers = API_OutboundTestHelper.assertCallFailed(apiCalls);assertCallSuccessful
global static List<API_Base> assertCallSuccessful(List<ApiCall__c> apiCalls)Tests that a web service call is executed successfully for each of the provided API calls.
Parameters:
apiCalls(List) - The API calls containing the services and parameters to call
Returns: API_Base - A list of handlers that processed the request
Since: 1.0
Example:
List<ApiCall__c> apiCalls = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
List<API_Base> handlers = API_OutboundTestHelper.assertCallSuccessful(apiCalls);assertCallSuccessful
global static API_Base assertCallSuccessful(String serviceName, Id recordId)Tests the successful execution of a web service call.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - Id of the triggering object (optional)
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
API_Base handler = API_OutboundTestHelper.assertCallSuccessful(SERVICE_NAME, record.Id);assertCallSuccessful
global static API_Base assertCallSuccessful(String serviceName, Id recordId, Map<String, String> parameters)Tests the successful execution of a web service call, passing a map of parameters.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameters(Map) - Map of parameters to pass to the API call
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
Map<String, String> parameters = new Map<String, String>{API_MyService.PARAM_KEY => 'value'};
API_Base handler = API_OutboundTestHelper.assertCallSuccessful(SERVICE_NAME, record.Id, parameters);assertCallSuccessful
global static API_Base assertCallSuccessful(String serviceName, Id recordId, Set<String> parameterNames)Tests the successful execution of a web service call, passing a set of parameters.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameterNames(Set) - Names of parameters to pass to the service handler
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
Set<String> parameterNames = new Set<String>{'param1', 'param2'};
API_Base handler = API_OutboundTestHelper.assertCallSuccessful(SERVICE_NAME, record.Id, parameterNames);assertCallSuccessful
global static API_Base assertCallSuccessful(String serviceName, Id recordId, String parameterName)Tests the successful execution of a web service call, passing a single parameter.
Parameters:
serviceName(String) - The name of the web service handlerrecordId(Id) - id of the triggering object (optional)parameterName(String) - Name of a parameter to pass to the service handler
Returns: API_Base - The handler executing the API call
Since: 1.0
Example:
API_Base handler = API_OutboundTestHelper.assertCallSuccessful(SERVICE_NAME, record.Id, API_MyService.PARAM_KEY);assertParseFailed
global static List<API_Base> assertParseFailed(List<ApiCall__c> apiCalls)Tests that a web service call fails to parse the response.
Parameters:
apiCalls(List) - The API calls containing the services and parameters to call
Returns: API_Base - A list of handlers that processed the request
Since: 1.0
Example:
List<ApiCall__c> apiCalls = TST_Factory.newOutboundApiCall(SERVICE_NAME, record.Id);
List<API_Base> handlers = API_OutboundTestHelper.assertParseFailed(apiCalls);