Callout Mock
An instance of the forvendi.BreezzApi.CalloutMock class is used for standardizing HttpCalloutMock instances in Apex unit tests.
It can be used standalone or in conjunction with CalloutMultiMock to set up mock responses across multiple HTTP endpoints.
withBaseUrl(String url)
Appends a base URL to the URL supplied when registering routes with CalloutMultiMock.addRoute(String url).
Signature: public forvendi.CalloutMock withBaseUrl(String url)
Parameters:
url: Base URL address of the endpoint being tested.
Return Value: forvendi.CalloutMock – The mock instance for fluent chaining.
withOrgBaseUrl()
Appends the current Salesforce org’s base URL to the endpoint route.
Signature: public forvendi.CalloutMock withOrgBaseUrl()
Return Value: forvendi.CalloutMock – The mock instance for fluent chaining.
withStatusCode(Integer statusCode)
Sets the HTTP response status code and corresponding status message.
Signature: public forvendi.CalloutMock withStatusCode(Integer statusCode)
Parameters:
statusCode: HTTP response status code (e.g., 200, 400, 500).
Return Value: forvendi.CalloutMock – The mock instance for fluent chaining.
withHeader(String name, String value)
Adds an HTTP header to the mock response.
Signature: public forvendi.CalloutMock withHeader(String name, String value)
Parameters:
name: Header parameter key (e.g., ‘Content-Type’).value: Header parameter value (e.g., ‘application/json’).
Return Value: forvendi.CalloutMock – The mock instance for fluent chaining.
withBody(String body)
Sets the body text/payload of the HTTP response.
Signature: public forvendi.CalloutMock withBody(String body)
Parameters:
body: String payload of the HTTP response.
Return Value: forvendi.CalloutMock – The mock instance for fluent chaining.
apply()
Registers the mock instance in its parent CalloutMultiMock container.
Signature: public forvendi.CalloutMultiMock apply()
Return Value: forvendi.CalloutMultiMock – Parent multi-mock instance for chaining additional route mocks.