API Method ScenarioExecuteLoop
This method is used to execute a single loop of the GenRocket engine. Use this method when it is absolutely necessary to control each iteration of the data generation life cycle. Also, using this method requires a thorough knowledge of the API.
Requirements
- The GenRocket API requires loading a valid Scenario in order to do security validation of the organization, user and licensing.
Exceptions
The following GenRocket exceptions may be thrown by this method:
- If the runtime instance is currently running another Scenario.
- If the Scenario cannot be validated for any number of reasons.
- If the User profile cannot be validated for any number of reasons.
Runtime Method Signature
Use this method signature when directly accessing the GenRocket binary runtime.
public void scenarioExecuteLoop()REST/Socket Payload Request
Use this API JSON request payload when making an API call to the GenRocket REST or Socket Engine.
{
"interfaceType": "Manual",
"method": "scenarioExecuteLoop",
"parameters": {
}
}REST/Socket Payload Successful Payload Response
The API JSON response payload for this method will be empty.
{
"responseType": "OK",
"data": ""
}Example Usage
In the example Groovy code below, the processData method does the following:
- References an API instance for a given Scenario by retrieving the reference from a map of Scenarios via the domainName parameter.
- Makes an API call to return the list of attribute name via the domainName parameter.
- Removes the id attribute name from the list of attribute names.
- Traverses the list of attribute names
- Retrieves the value of for the current attributeName from the data map.
- Concatenates the domainName with the attributeName to create the attribute's canonicalName
- Replace the Attribute's Generator with a ConstantGen Generator with the new value.
- Makes an API call to execute one loop of the Scenario.
void processData(String domainName, Map<String, String> data) {
final EngineManual api = scenarios.get(domainName)
final List<String> attributes = api.attributes(domainName)
attributes.remove('id')
attributes.each { attributeName ->
final String value = data[attributeName]
final String canonicalName = "${domainName}.${attributeName}".toString()
api.generatorReplace(canonicalName, ConstantGen, 0, false, [value: value])
}
api.scenarioExecuteLoop()
}
Article Feedback: Was this helpful?
Give feedback