Question 1
Choose 1
Northern Trail Outfitters (NTO) wants to improve the quality of callouts from Salesforce to
its REST APIs. For this purpose, NTO will require all API Clients/consumers to adhere to
REST API Markup Language (RAML) specifications that include the field-level definition of
every API request and response Payload. The RAML specs serve as interface contracts
that Apex REST API Clients can rely on. Which design specification should the integration
architect include in the integration architecture to ensure that Apex REST API Clients’ unit
tests confirm Adherence to the RAML specs?
Correct answer:
C. Implement HttpCalloutMock to return responses per RAML specification
Explanation:
Apex requires unit tests for callout logic, and Salesforce does not allow real HTTP callouts during test execution. Developers must use the HttpCalloutMock interface to simulate the external endpoint's response. The key requirement here is that the unit tests must confirm adherence to the RAML specification, meaning the mock responses need to be built directly from the field-level request and response payload definitions in the RAML contract.
By implementing HttpCalloutMock so that it returns responses that precisely match the structure, fields, and data types defined in the RAML specification, the architect ensures that:
The Apex client code is tested against a realistic, contract-accurate response.
Any mismatch between what the Apex code expects and what the actual API contract defines, such as missing fields, incorrect data types, or unexpected null values, will surface as test failures.
The tests validate actual adherence to the interface contract, rather than simply confirming that a callout occurred without throwing an exception.
This makes the mock the actual mechanism for validating conformance to the RAML specification. It is not enough to simply use a mock or invoke it; the mock's content must be driven by the specification for the tests to provide meaningful contract validation.
Why not the others:
A. Require Clients to implement HttpCalloutMock:
This only states that mocking must be used. It is a necessary but insufficient design specification because it says nothing about validating adherence to the RAML contract itself. Any mock implementation, including one returning arbitrary or incorrect data, would satisfy this requirement, defeating the purpose of the validation.
B. Call the HttpCalloutMock implementation from the clients:
This describes basic test setup mechanics, such as using Test.setMock() to inject the mock, but it does not address the actual goal of confirming that payloads conform to RAML. Implementing and invoking a mock without RAML-based content does not prove specification adherence.
Key exam takeaway
The differentiator is what the mock returns, not simply that a mock exists or is invoked. To validate a contract, test doubles should be built from that contract.
Reference
Apex Developer Guide - Testing HTTP Callouts (HttpCalloutMock interface, Test.setMock())
Apex requires unit tests for callout logic, and Salesforce does not allow real HTTP callouts during test execution. Developers must use the HttpCalloutMock interface to simulate the external endpoint's response. The key requirement here is that the unit tests must confirm adherence to the RAML specification, meaning the mock responses need to be built directly from the field-level request and response payload definitions in the RAML contract.
By implementing HttpCalloutMock so that it returns responses that precisely match the structure, fields, and data types defined in the RAML specification, the architect ensures that:
The Apex client code is tested against a realistic, contract-accurate response.
Any mismatch between what the Apex code expects and what the actual API contract defines, such as missing fields, incorrect data types, or unexpected null values, will surface as test failures.
The tests validate actual adherence to the interface contract, rather than simply confirming that a callout occurred without throwing an exception.
This makes the mock the actual mechanism for validating conformance to the RAML specification. It is not enough to simply use a mock or invoke it; the mock's content must be driven by the specification for the tests to provide meaningful contract validation.
Why not the others:
A. Require Clients to implement HttpCalloutMock:
This only states that mocking must be used. It is a necessary but insufficient design specification because it says nothing about validating adherence to the RAML contract itself. Any mock implementation, including one returning arbitrary or incorrect data, would satisfy this requirement, defeating the purpose of the validation.
B. Call the HttpCalloutMock implementation from the clients:
This describes basic test setup mechanics, such as using Test.setMock() to inject the mock, but it does not address the actual goal of confirming that payloads conform to RAML. Implementing and invoking a mock without RAML-based content does not prove specification adherence.
Key exam takeaway
The differentiator is what the mock returns, not simply that a mock exists or is invoked. To validate a contract, test doubles should be built from that contract.
Reference
Apex Developer Guide - Testing HTTP Callouts (HttpCalloutMock interface, Test.setMock())
