ACTION.JSON

{
  "name": "getIP",
  "protocol": "REST",
  "method": "GET",
  "entitypath": "{base_path}/{version}/addresses/{pathv1}",
  "schema": "schema.json",
  "timeout": 3000,
  "datatype": "PLAIN",
  "sendEmpty": true,
  "headers": {},
  "responseObjects": [
    {
      "type": "default",
      "key": "",
      "mockFile": "mockdatafiles/getIP-default.json"
    }
  ]
},



ACTION.JSON

    {
      "name": "getIP",
      "entitypath": "{base_path}/{version}/addresses/{pathv1}?{query}",
	….
      "responseObjects": [
        {
          "type": "name-abc123",
          "key": "",
          "mockFile": "a.json"
        },
        {
          "type": "error",
          "key": "",
          "mockFile": "b.json"
        },
        {
          "type": "name=happy",
          "key": "",
          "mockFile": "c.json"
        }
      ]
    },

  • Can still support different mock data based on the URI structure:
    • path variables (withPathv#)
    • query (withQuery)
  • On a call with a path variable – http://system:80/path/ver/addresses/abc123 the y.json is returned
  • On a call with a query variable – http://system:80/path/ver/addresses?name=abc123 the z.json is returned.
  • Otherwise the x.json is returned.

ACTION.JSON

    {
      "name": "getIP",
      "entitypath": "{base_path}/{version}/addresses/{pathv1}?{query}",
	….
      "responseObjects": [
        {
          "type": "default",
          "key": "",
          "mockFile": "x.json"
        },
        {
          "type": "withPathv1",
          "key": "",
          "mockFile": "y.json"
        },
        {
          "type": "withQuery",
          "key": "",
          "mockFile": "z.json"
        }
      ]
    },

Capture Mock Data from Postman

This image illustrates the response body when mock data is captured using Postman.


ADAPTERTESTINTEGRATION.JS

const isSaveMockData = true;
const stub = false;
...

describe ('#createDeployment-errors', () => {
  it('should work if integrated or standalone with mockdata', (done) => {
    try {
      a.createDeployment(apisApiId, apisCreateDeploymentBodyParam, null, 
(data, error) => {
        try {
          runCommonAsserts(data, error);
          if (stub) {
            assert.equal('string', data.response.CreatedDate);
            assert.equal('string', data.response.DeploymentId);
            ...
          } else {
            assert.equal('string', data.response.CreatedDate);
          }
          saveMockData('Apis', 'createDeployment', 'default', data);
          done();
        } catch (err) {
          log.error(`Test Failure: ${err}`);
          done(err);
        }
      });
    } catch (error) {
      log.error(`Adapter Exception: ${error}`);
      done(error);
    }
  }).timeout(attemptTimeout);
});


ADAPTERTESTINTEGRATION.JS

return_raw: true,
...

describe ('#createDeployment-errors', () => {
  it('should work if integrated or standalone with mockdata', (done) => {
    try {
      a.createDeployment(apisApiId, apisCreateDeploymentBodyParam, null, 
(data, error) => {
        try {
          runCommonAsserts(data, error);
          if (stub) {
            assert.equal('string', data.response.CreatedDate);
            assert.equal('string', data.response.DeploymentId);
            ...
          } else {
            assert.equal('string', data.response.CreatedDate);
          }
          saveMockData('Apis', 'createDeployment', 'default', data);
          done();
        } catch (err) {
          log.error(`Test Failure: ${err}`);
          done(err);
        }
      });
    } catch (error) {
      log.error(`Adapter Exception: ${error}`);
      done(error);
    }
  }).timeout(attemptTimeout);
});


ADAPTER LOGS

debug: Test-eai-connectorRest-makeRequest: CALL RETURN:  
{"status":"success","code":201,"response":"{\n\"type\" : 
\"oci/card\",\n\"id\" : 308,\n\"href\" : 
\"oci/card/308\",\n\"transientAttributes\"  : { },\n\"key\" :
{\n\"type\" : \"oci/cardKey\",\n\"keyValue\"  : 308\n}\n}","redirects":0,"tripTime":"197ms"}

CALL RESPONSE –This is the response or a partial response after JSON parsing.


ADAPTER LOGS

debug: Test-eai-restHandler-handleRestRequest: RESPONSE: 
{"type":"oci/card","id":308,"href":"oci/card/308","transientAttributes"
:{},"key" :{"type":"oci/cardKey","keyValue":308}}