Skip to content

EN.03.08.User Defined Variables

stormcat24 edited this page Aug 29, 2014 · 1 revision

There are user defined variables on Aeromock, refer to the following.

  • Template data file
  • JSON API data file
  • routing.groovy
  • data.groovy
  • ajax.groovy
  • Custom tag, function script.

variable.groovy

Create variable.groovy at project root directory. If this script returns Map object, be able to refer entries of Map at data file and various script.

return [
    custom_prop1: "custom_prop1_value",
    custom_propmap: [
        id: 100,
        value: "test"
    ]
]

Then, be able to refer to bultin variables at variable.groovy. That is be able to change user defined variables dynamically by using User-Agent and query parameters.

Refer to user defined variables

For example in data file, refer to as follows.

custom_prop1: ${custom_prop1}
custom_propmap_id: ${custom_propmap.id}
custom_propmap_value: ${custom_propmap.value}

Overwrite builtin variables

It's possible to overwrite user defined variables to builtin variables.

Clone this wiki locally