Work with mock data
Mock data is the response an adapter returns when running in stub mode. Instead of making a live call to the external system, the adapter runs through its full processing pipeline and returns the stored mock data at the point where the real call would occur. This allows you to test the complete data flow through the adapter — including schema translation — without integrating with a live system.
Stub mode is also useful for buildingItential Platform workflows when the external system is not yet available.
Mock data cannot test authentication, confirm that URLs are correct, or guarantee the response reflects the current state of the external system. Mock data is also not automatically maintained — if the external system’s API changes, mock data files may need to be updated manually.
Mock data file format
Mock data is the raw response body from the external system. It should match the responseDatatype defined in action.json — typically JSON.
Simple format — the file contains only the response body:
Status/response format — an older format that wraps the response body in a response object and adds a status field. Use this format when you need to simulate specific HTTP status codes, such as error responses, since mock data files do not contain real HTTP headers.
Define mock data files in action.json
Each action in action.json has a responseObjects array that tells the adapter which mock data file to return when running in stub mode. The mockFile path is relative to the entity directory — keep mock data files in a mockdatafiles/ subdirectory to avoid cluttering the entity root.
Use multiple mock data files per action
An action can define multiple entries in responseObjects, each pointing to a different mock file. The adapter selects which file to return based on the incoming request, using the following hierarchy:
- Match data in the request body
- Match data in a path variable
- Match data in a query or option parameter
- Request has a body (
withBody) - Request has a path variable (
withPathv#) - Request has a query parameter (
withQuery) - Request has an option parameter (
withOption) - Default
Example: match-based selection. The type field in each responseObject entry specifies the match value. In this example, a request with { name: 'abc123' } in the body returns a.json, a request with path variable error returns b.json, and a request with query name=happy returns c.json:
Example: structural selection. Use withPathv#, withQuery, or default as the type to select based on whether the request includes a path variable, a query parameter, or neither:
Capture mock data
From Postman
Run the API call in Postman, then copy the response body from the response panel and save it as a JSON file in the mockdatafiles/ directory of the appropriate entity. Reference the file in the corresponding action.json responseObjects entry.
From integration tests
Set isSaveMockData to true and stub to false in adapterTestIntegration.js, then run the integration tests. The adapter makes live calls to the external system, saves each response as a mock data file, and updates the corresponding action.json entries automatically.
By default, saveMockData saves the translated response. If you want to save the raw, pre-translation response instead, set return_raw: true in the request properties. When return_raw is enabled, saveMockData uses the raw response data, so you do not need to manually revert the translation.
From adapter logs
Enable debug-level logging on the adapter, then run the call. Two log entries contain the response data:
CALL RETURN — the full response body before JSON parsing. Use this for mock data when you want the raw response.
CALL RESPONSE — the response after JSON parsing. Use this when you want the parsed object.
Copy the relevant value and save it as a JSON file in the mockdatafiles/ directory of the appropriate entity.