Description
The GMUS can modify any Scenario, in real-time, prior to its execution, by adding GenRocket API commands to the request payload. The following Groovy method adds API sub-elements to the request payload to take the following actions on the loaded Scenario before execution:
- scenarioClear
- domainAdd
- attributeAdd
- generatorAdd
- receiverAdd
- domainSetLoopCount
The loading of the Scenario and running of the Scenario will be taken care of by GMUS.
def scenarioAPIQ() { Map response = [:] try { def hTTPBuilder = new AsyncHTTPBuilder( threadPool: Executors.newFixedThreadPool(5000), uri: "http://localhost:8070/rest/scenario", contentType: ContentType.JSON) hTTPBuilder.ignoreSSLIssues() hTTPBuilder.request(Method.POST, ContentType.JSON) { body = ["clientAppId" : "XXXXXXXX-487e-41e2-8245-XXXXXXXXXXXX", "clientUserId": "XXXXXXXX-0777-426f-be33-XXXXXXXXXXXX", "username" : "jane.doe@gmail.com", "scenario" : "UserScenario.grs", "scenarioPath": "/home/UserName/Downloads/output", "inMemory" : false, "api" : [ [resources: ["resource.output.directory": "/home/johndoe/Desktop/output"], [methodName: "scenarioClear"], [methodName: "domainAdd", parameters: [domainName: "User", primary: true]], [methodName: "attributeAdd", parameters: [attributeName: "User.ssn"]], [methodName: "generatorAdd", parameters: [attributeName : "User.ssn", generatorName : "com.genRocket.generator.RangeConstantGen", requiredGeneratorParameters: [suffix: "firstName", prefix: "#{User.id}"]]], [methodName: "receiverAdd", parameters: [ domainName : "User", canonicalName: "com.genRocket.receiver.XMLFileReceiver", receiverName : "XMLFileReceiver", parameterMap : [ path : '#{resource.output.directory}', fileName: "User.xml".toString() ]]], [methodName: "domainSetLoopCount", parameters: [domainName: "User", loopCount: "100000".toString()]] ] ] response.success = { resp, json -> response = json } response.failure = { resp -> response = [message: "Request failed with status ${resp.status}"] } } } catch (Exception ex) { ex.printStackTrace() response = [message: ex.message] } return response }