Description

This is an example of how the conditions of a Scenario can be modified, using the GenRocket API, prior to running the Scenario.

  • The User Domain's loopCount parameter is set to 100
  • The User.id Attribute's RangeGen.startRange parameter is set to '101'
  • The User.emailAddress Attribute's EmailGen.suffix parameter is set to 'test'

Activity Diagram

The activity diagram defines the steps and API calls necessary to load, modify and run the Scenario. 

Groovy Source Code Example

package com.genRocket.engine.examples

import com.genRocket.GenRocketException
import com.genRocket.engine.EngineAPI
import com.genRocket.engine.EngineManual

/**
 * Created by Hycel Taylor on 12/29/16.
 *
 * This is an example of how the conditions of a Scenario can be modified,
 * using the GenRocket API, prior to running the Scenario.  The following
 * conditions are modified:
 * <ul>
 * <li>The User Domain's loopCount is set to 100</li>
 * <li>The User.id Attribute's RangeGen.startRange parameter is set to '101'</li>
 * <li>The User.emailAddress Attribute's EmailGen.suffix parameter is set to 'gmail.com'</li>
 * </ul>
 */
class ModifyConditions {

  public static void main(String[] args) {
    String scenario = '/home/userName/UserScenario.grs'
    String domainName = 'User'
    Integer position = 0

    EngineAPI api = new EngineManual()

    try {
      // Initialize Scenario
      api.scenarioLoad(scenario)
      api.domainSetLoopCount(domainName, 100.toString())

      // Initialize the startRange parameter to 101 on the RangeGen
      String attributeName = "${domainName}.id"
      api.generatorParameterSet(attributeName, position, 'startRange', '101')

      // Update the suffix parameter to 'gmail' on the EmailGen Generator
      attributeName = "${domainName}.emailAddress"
      api.generatorParameterSet(attributeName, position, 'suffix', 'gmail.com')

      // Run Scenario
      api.scenarioRun()
    } catch (GenRocketException e) {
      println(e.getMessage())
    }
  }
}