ol test asset

Test an asset against the module datasource

The ol test asset command performs a dry run of the request-response interaction between the OL Hub and a data source. Thus, the test can give immediate feedback on the asset capacity to run the business operation on the data source, give it an input, and see if it returns an expected output. 

The command is dependent on a pre-existing testing setup that was automatically generated by a prior ol add command execution or on tests that you create using the ol create test command. The setup includes three JSON files stored in the test_data/case-1 folder located under the asset folder. The three files are in.json, out.json, and metadata.json. in.json specifies the data that will be sent as input to the data-source business operation, and out.json specifies the data returned as output in a successful request.  metadata.json specifies the success status code of the test.

The command can only be executed from the module folder containing a module.json file with populated connection properties. It receives the name of the tested asset as an argument and refers to in.json to read the test data. It then connects to the remote data source using the connection properties specified in module.json. If the request is successful, the returned data is written to out.json, and a 200 status-code is registered in metadata.json. If the request fails, an error code is registered in metadata.json

An in.json file before the test:

{ 
  "dfhcommarea" : {
      "innerRecord" : [ {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      }, {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      }, {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      }, {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      }, {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      }, {
        "itemNumber" : 0,
        "itemName" : "",
        "description" : ""
      } ]
    }
}

An out.json with data after the test:

{
  "dfhcommarea" : {
    "innerRecord" : [ {
      "itemNumber" : 1000,
      "itemName" : "Kid Guitar",
      "description" : "Kids Guitar - Musical Toys"
    }, {
      "itemNumber" : 1001,
      "itemName" : "Ball Pool",
      "description" : "Ball Pool - Novelty Toys"
    }, {
      "itemNumber" : 1002,
      "itemName" : "Water Ball",
      "description" : "Water Ball - Balls"
    }, {
      "itemNumber" : 1003,
      "itemName" : "Frisbee",
      "description" : "Dog Frisbee - Pet Toys"
    }, {
      "itemNumber" : 1004,
      "itemName" : "Pig Bank",
      "description" : "Pig Saving Bank - Ceramics"
    } ]
  }
}
  • Login to the OL Hub.
  • Execute the command from the module root folder.
  • A prior execution of the ol add command has generated the module’s asset and testing file structure.

Syntax

ol test asset ASSET_NAME [CASE_NAME] [OPTIONS]

Arguments

ASSET_NAME (required)

The name of the asset to be tested

CASE_NAME

The name of the test case you want to test (default: 1)

Options

--profile

The configuration profile

--record

Record test asset network traffic

--use-recording

Use recorded network traffic to test asset

Examples

Testing mainframe-based operation

> ol test asset itemde
$ ol test asset itemde

Testing a specified test case

temp> ol test asset itemde 2
temp$ ol test asset itemde 2