Callout Multi Mock
Instance of forvendi.BreezzApi.CalloutMultiMock class used for creating HttpCalloutMock with multiple Endpoints. Used in conjuction with forvendi.BreezzApi.CalloutMock to configure respective endpoints. CalloutMultiMock stores multiple CalloutMocks and returns appropriate HttpResponse based on configuration.
addRoute(String method, String url)
Creates a child mock that will be matched against a given HTTP method and URL pattern.
Signature:
forvendi.BreezzApi.CalloutMock.addRoute(String method, String url);
Parameters:
- method - HTTP method
- url - Endpoint URL
Return:
CalloutMock - The child mock for further configuration
CalloutMultiMock Example: Creating a mock with multiple endpoints
Creating instance of CalloutMultiMock is required. (Most likely with BreezzApi.TESTS.setCalloutMultiMock() method). To configure a single endpoint refer to CalloutMock.
1BreezzApi.TESTS.setCalloutMultiMock()
2 .addRoute('GET', '/services/data/v57.0/tooling/sobjects/ContainerAsyncRequest/(\\w+{18})')
3 .withOrgBaseUrl()
4 .withStatusCode(200)
5 .withHeader('Content-Type', 'application/json')
6 .withBody(
7 '{"State":"Failed","DeployDetails":{"allComponentMessages":[{"problem":"ERROR"}]}}'
8 )
9 .apply()
10 .addRoute('POST', '/services/data/v57.0/tooling/sobjects/ContainerAsyncRequest')
11 .withOrgBaseUrl()
12 .withStatusCode(201)
13 .withHeader('Content-Type', 'application/json')
14 .withBody('{"id":"001000000000000AAA","success":true}')
15 .apply()
16 .addRoute('POST', '/services/data/v57.0/tooling/sobjects/ApexClassMember')
17 .withOrgBaseUrl()
18 .withStatusCode(201)
19 .withHeader('Content-Type', 'application/json')
20 .withBody('{"id":"002000000000000AAA","success":true}')
21 .apply()
22 .addRoute('POST', '/services/data/v57.0/tooling/sobjects/ApexTriggerMember')
23 .withOrgBaseUrl()
24 .withStatusCode(201)
25 .withHeader('Content-Type', 'application/json')
26 .withBody('{"id":"003000000000000AAA","success":true}')
27 .apply()
28 .addRoute('POST', '/services/data/v57.0/tooling/sobjects/MetadataContainer')
29 .withOrgBaseUrl()
30 .withStatusCode(201)
31 .withHeader('Content-Type', 'application/json')
32 .withBody('{"id":"005000000000000AAA","success":true}')
33 .apply()
34 .addRoute('GET', '/services/data/v57.0/tooling/query')
35 .withOrgBaseUrl()
36 .withStatusCode(200)
37 .withHeader('Content-Type', 'application/json')
38 .withBody('{"records":[{"id":"006000000000000AAA"}]}')
39 .apply();