Test Data Structures

Model Override

There are situations when you need to generate more rows than what is specified in the iteration settings in the model, or you need to use different CSV files than the ones that are defined in the model. In these situations, use a Model Override.

A Model Override consists of three optional sections:

Model Override Structure

{
	model: DataModel,		      // Data Model Override
	context: DataSourceContext,	      // Context Override (CSV)
	iterationOverride: IterationOverride, // Iteration Override
}

Data Model Override

You use a Data Model Override when you need to override some entities in the Data Model. Entities from the Data Model Override are copied to the Data Model that we generate data for. If a Data Entity with that name already exists, it’s replaced, if it doesn’t exist, the Data Entity is added to the Data Model. The structure of the override is a Multi Entity Model.

Sample Data Model Override

"model": {
	"id": "datamodel/PetStore",
	"title": "Pet Store",
	"description": "A Pet Store model",
	"kind": "tdm",
	"entities": {
	  "pet": {
		"type": "object",
		"repeat": 1,
		"properties": {
		  "name": {
			"type": "string"
		  },
		  "email": {
			"type": "string"
		  }
		},
		"requirements": {
		  "name": "randText(5, 10)",
		  "email": "$name + '@google.com'"
		}
	  },
	  "user": {
		"type": "object",
		"repeat": 1,
		"properties": {
		  "name": {
			"type": "string"
		  },
		  "ownerOf": {
			"type": "string"
		  }
		},
		"requirements": {
		  "name": "randText(5, 10)",
		  "ownerOf": "${pet.name}"
		}
	  }
	}
}

Iteration Override

You use an Iteration Override when you want to use different iteration settings than what is defined in the Data Model.

Sample Iteration Override

"iterationOverride": {
	"user": {
		"repeat": 10
	}
}

Context Override

The Context Override is used when you want to change the CSV files used in the Data Sources to generate data.

Sample Context Override

"context": {
	"csvs": [
		"name": "some name",	    // name used in the data source to reference the file
		"location": "some_file.csv" // URL of the CSV file
]
}

Billing Limits

The Billing limits structure describes how your account's billing limits were applied when data was generated.

Sample Billing Limits

"billingLimits": {
    "total": 10000,        // max generated rows from billing plan
    "entity": {
      "user": {
        "apply": true,     // billing limits should be applied to this entity
        "applied": false,  // were billing limits applied? (e.g. was the number of rows higher than “total”
        "requested": 5,    // how many were requested to generate
        "generated": 5     // how many were actually generated
      }
    }
}

API Publish Config

The API Publish Config maps data to sequences of one or more HTTP requests. The goal is to publish data to a target service or delete data from target service.

The API Publish Config is an associative array, where the keys are the names of Data Model Entities, and the values are create and optionally delete configurations. Each configuration can contain one or more Publish steps that create or delete data.

Note: The ? symbol denotes that a property is optional. In this case, the delete step is optional.

Each CreateConfig structure is one step. Steps are executed sequentially. The CreateConfig and DeleteConfig both have the same structure.

The properties url, headers, and request are TypesScript template literals. Please consult the TypeScript documentation to find out what can be done in these templates.

Use the result to extract values from the HTTP response and store the value in a local or data model variable. The keys in the resulting associative array are variable names, and the values are JSON pointers.

Sample API Publish Config

{
	someEntityName: {
		create: CreateConfig[],
		delete?: DeleteConfig[]
    }
}

Sample CreateConfig/DeleteConfig structure

{
    method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH",
    url: string,
    headers?: {
        [header: string]: string
    },
    request?: string;
    result?: {
        [paramName: string]: string
    }
}

Request Config

Use a Request Config if you need to configure authentication and an HTTP proxy for the Publish Config HTTP requests.

Note: Only basic authentication is supported at this time.

Sample Request Config

{
    auth?: {
        username: string;
        password: string;
    };
    xsrfCookieName?: string;
    xsrfHeaderName?: string;
    proxy?: {
        protocol?: string;
        host?: string;
        port?: number;
        auth?: {
            username: string;
            password: string;
        };
    };
};

Private Location Config

When you want to publish data to a Private Location, you need to specify the private location by providing it's shipID and harborId.

Sample Private Location Config

{
    harborId: string,
    shipId: string,
}