Description
The API Recording feature works just like a digital record to allow API method calls to be recorded before the API scenarioRun() method is called. The Recorder is a powerful API feature because it allows Scenarios that are related to each other, via their internal Domain ancestry, to load and play recordings that will automatically set the conditions of parent and sibling Domains before the scenarioRun() method is called.
Recording Methods
- Recording Overview
- recordingNew(String recordingName, Boolean overwrite)
- recordingStart()
- recordingPause()
- recordingStop()
- recordingLoad(String recordingName)
- recordingPlay()
- recordingDelete(String recordingName)
- List<String> recordings()
- Map<String, Object> recordingShow(String recordingName)
Groovy Code Example
The example Groovy class contains two method testUserRecordingNew() and testAddressRecordLoadAndPlayback().
Method - testUserRecordingNew()
The UserScenario has the following configuration:
- Contains one Domain, User Domain
- User Domain is associated to an XMLFileReciever
- User.loopCount = 10
- User.id's RangeGen.startRange = 1
- User.emailAddress EmailGen.suffix = 'example'
Method testUserRecordingNew() will perform the following sequence of commands:
- Load the UserScenario
- Create a new Recording
- Start the Recording
- Record the api method call to set the User.loopCount = 10000
- Record the api method call to set the User.id's RangeGen.startRange = 101
- Record the api method call to set the User.emailAddress 's Generator.suffix parameter = 'gmail'
- Run the UserScenario
Method - testAddressRecordLoadAndPlayback()
The AddressScenario has the following configuration:
- Contains two Domains, the User Domain and the Address Domain
- Address Domain is associated to an SQLFileReciever
- The User Domain is the Parent to the Address Domain
- Address.user's ReferenceGen, references the User.id
- Address.emailAddress's ReferenceGen, reference the User.emailAddress
Method testAddressRecordLoadAndPlayback() will perform the following sequence of commands:
- Load the AddressScenario
- Load the GenRocket.UserRecording
- Play the recording to modify User Domain
- Run the AddressScenario
Groovy Source Code
class APIRecorderExamples { public static final String home = System.getProperty("user.home") public static final String userScenario = "${home}/Downloads/UserScenario.grs" public static final String addressScenario = "${home}/htaylor/Downloads/AddressScenario.grs" public static final String recordingName = 'GenRocket.UserRecording' /* * Method - testUserRecordingNew() * * Load the UserScenario * Create a new Recording * Start the Recording * Record the api method call to set the User.loopCount = 10000 * Record the api method call to set the User.id's Generator.startRange parameter to 101 * Record the api method call to set the User.emailAddress 's Generator.suffix parameter to 'gmail' * Run the UserScenario **/ void testUserRecordingNew() { final String domainName = 'User' final Integer position = 0 final EngineAPI api = new EngineManual() try { // Initialize Scenario api.scenarioLoad(userScenario) // Create a new recording api.recordingNew(recordingName, true) // Start Recording api.recordingStart() // Set the Domain's loopCount to 10000 api.domainSetLoopCount(domainName, 10000.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') // Run Scenario api.scenarioRun() } catch (GenRocketException e) { println(e.getMessage()) } } /** * Method - testAddressRecordLoadAndPlayback() * * Load the AddressScenario * Load the GenRocket.UserRecording * Play the recording to modify User Domain * Run the AddressScenario **/ void testAddressRecordLoadAndPlayback() { final EngineAPI api = new EngineManual() try { // Initialize Scenario api.scenarioLoad(addressScenario) // Create a new recording api.recordingLoad(recordingName) // Play the Recording api.recordingPlay() // Run Scenario api.scenarioRun() } catch (GenRocketException e) { println(e.getMessage()) } } public static void main(String[] args) { APIRecorderExamples recorder = new APIRecorderExamples() recorder.testUserRecordingNew() recorder.testAddressRecordLoadAndPlayback() } }
Sample UserScenario Output (limited to 1st 5 and last 5 rows)
<rows> <row id="101" firstName="Charissa" lastName="Mahan" middleInitial="J" username="user101" password="38B3EFF8BAF56627478EC76A704E9B52" emailAddress="user101@gmail.com"/> <row id="102" firstName="Maybelle" lastName="Silverstein" middleInitial="E" username="user102" password="EC8956637A99787BD197EACD77ACCE5E" emailAddress="user102@gmail.com"/> <row id="103" firstName="Arletta" lastName="Alfano" middleInitial="U" username="user103" password="6974CE5AC660610B44D9B9FED0FF9548" emailAddress="user103@gmail.com"/> <row id="104" firstName="Estell" lastName="Gandara" middleInitial="S" username="user104" password="C9E1074F5B3F9FC8EA15D152ADD07294" emailAddress="user104@gmail.com"/> <row id="105" firstName="Era" lastName="Mangold" middleInitial="X" username="user105" password="65B9EEA6E1CC6BB9F0CD2A47751A186F" emailAddress="user105@gmail.com"/> <!-- ... --> <row id="10096" firstName="Maricela" lastName="Vallejo" middleInitial="Q" username="user10096" password="EE4117572AFBC0CF760F70714AF0EC52" emailAddress="user10096@gmail.com"/> <row id="10097" firstName="Tawanna" lastName="Stapleton" middleInitial="K" username="user10097" password="23B702C4C421DDB2D023FEE968C0D839" emailAddress="user10097@gmail.com"/> <row id="10098" firstName="Karine" lastName="Strack" middleInitial="C" username="user10098" password="C876914F82CE54CB533B186AFD41166E" emailAddress="user10098@gmail.com"/> <row id="10099" firstName="Cynthia" lastName="Stockton" middleInitial="D" username="user10099" password="995CA733E3657FF9F5F3C823D73371E1" emailAddress="user10099@gmail.com"/> <row id="10100" firstName="Branda" lastName="Malloy" middleInitial="X" username="user10100" password="AC2D43EF3F26CC74DE242202E822ECB0" emailAddress="user10100@gmail.com"/> </rows>
Sample AddressScenario Output (limited to 1st 5 and last 5 rows)
insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('1','1000 N Washington Dr','Topeka','KS','66601','101','user101@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('2','1001 S Adams Sq','Baton Rouge','LA','70801','102','user102@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('3','1002 E Jefferson Ct','Augusta','ME','04330','103','user103@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('4','1003 W Madison St','Providence','RI','02901','104','user104@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('5','1004 NS Monroe Rd','Washington','DC','20001','105','user105@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('9996','10995 NE Van Buren Pkwy','Austin','TX','73301','10096','user10096@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('9997','10996 NW Harrison Dr','Trenton','NJ','08601','10097','user10097@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('9998','10997 SE Tyler Sq','Augusta','ME','04330','10098','user10098@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('9999','10998 SW Polk Ct','Phoenix','AZ','85001','10099','user10099@gmail.com'); insert into address(id,address,city,state,zip_code,user,userEmailAddress) values ('10000','10999 EW Taylor St','Sacramento','CA','94203','10100','user10100@gmail.com');