Adding Event Hooks in Configuration sheet for custom functionality
Search Knowledge Base by Keyword
Event Hooks provide a way to add custom functionality to the configuration sheet for generating synthetic test data. The following examples in the Sample Commerce domain demonstrate how to use Event Hooks in Synthetic Test Data Generation. Event Hooks allow the user to customise the functionality for calculations that may require business logic.
1. Total Amount Example
The Total Amount is based on the number of Order items multiplied by the Unit price.
What is the Event Hooks tab?
It’s a way to specify doing a certain calculation before or after another calculation. So for example when you want to add up the Total Order Amount for a particular customer, it is necessary to first do a summation for each product bought based on the product price multiplied by the quantity. The productTotal for each product is then added together to form the Total Amount sold (The multiplication process (amount * quantity) must be done ahead of the summation process).
In our example, there are 2 tabs to consider:
- EventHooks
- EventHooksParameter
If we look at the EventHooks tab,
We can see that there is a Process called UpdateTotalOrderValue which refers to a VIP flow called UpdateTotalOrderValue.vip. Further note that the scope of the flow is OrderItem. The ‘When’ column can either be set to ‘After’ or ‘Before’. ‘After’ means the process should be executed after all OrderItems have been created/saved. ‘Before’ means the process should be executed before any of theOrderItems are created/saved. This allows the user to be able to manipulate the Order before generating any OrderItem which is sometimes useful if you want to manipulate and propagate a value to all the OrderItems of a current Order.
If we look at EventHooksParameters,
We see that there are 2 parameters for processing UpdateTotalOrderValue and they are 1) parOrder and 2) parOrderItems which contains the necessary information for calculating the TotalOrderValue. Variable lst_OrderItem is the way that the list of OrderItems is passed down to other flows. Variable values are passed down to other flows through the Variable field. In this case, the list of OrderItems is passed through lst_OrderItem_ . (The ‘_’ before and after the application object is a convention so if we had been working with products, the variable would be lst_Product_.)
Note that the OrderItem Table contains both the UnitPrice and the Quantity.
2. Example for Referring Columns from the Same Table
In this section we will look at another example in the Sample Commerce domain for referring Columns from the same Table. In this example, we would like the phone & fax numbers to be the same. The way to do this is when the Supplier’s Phone value is assigned in our tables, we can also assign the same value to our Supplier Fax value.
If you look at line 7 in the Supplier Table above, which contains the object _Supplier_..Phone., you can see that when _Supplier_.Phone is assigned a value, that value is also assigned to _Supplier_.Fax. This process results in the phone and fax variables being the same. Note that Columns can only be referred downwards i.e. the Column defined in Row 7 can be used in Row 8 column but Column defined in Row 9 cannot be used in Row 8 Column. If you would like, it is possible for you to manipulate the order of rows in which the column is defined.
3. Example for Referring Existing Data (varTargetRepo)
This example demonstrates how to use selected variable values across multiple tables.
This example focuses on the object Country.
If we look at line 5 of the Customer Table below:
We see that Country is being populated based on existing Countries that are already part of the System.
If we look at line 6 in the PreProcessVariables table above, we see that there is a database query to select the top 100 Countries from the Country repository. The value is assigned to varExisting_Country_. Once this is done, we have a list of countries that are available in the Database and can be referenced by any of our tables.
See line 5 in the Customer Table:
and line 6 in the Supplier Table below.
This example shows how to reference the same variable across multiple tables.
-
-
-
- IEnumerable to Data Reader
- Data Table to List
- Nested String List to Data Table
- List to Data Table
- IEnumerable to List
- List to IEnumerable
- Remove from List
- Exists in List
- Value Exists in Dictionary
- Key Exists in Dictionary
- Remove from Dictionary
- Get from Dictionary
- Clear Dictionary
- Add to Dictionary
- Clear List
- Add to List
- Show all articles ( 1 ) Collapse Articles
-
-
-
-
- Explanation of Remaining Sheets in the Control Spreadsheet (for reference only)
- The ForeignKeys Sheet - Specifying which Foreign Keys to read from the Source Database
- The Tables Sheet: Defining Metadata that will be read from the Source Database
- The ProcessModel sheet – Toggling Subset Rules
- Refining the Control Spreadsheet
- Overview of the Advanced Control Spreadsheet
- Introduction
-
- Drop both Primary and Foreign Keys (The composite DROPKEYS Action)
- Validate Both Primary and Foreign Keys (The composite ValidateKeys Action)
- Add Both Primary and Foreign Keys (The Composite ADDKEYS action)
- Drop Tables
- Truncate Data
- Delete Orphans
- Drop Primary Keys
- Drop Foreign Keys
- Validate that Foreign Keys are Unique
- Validate that Primary Keys are Unique
- Add Foreign Keys
- Add Primary Keys
- Overview of Post-Subset Actions
-
-
- Use Event Hooks to call VIP Flows
- Different Methods for Connecting to Source Databases
- PreProcess Variables and Parameters
- Using SQL Functions to query Databases and Using the Queries in Data Generation Functions
- Summary of the Process to Configure the Test Data Configuration sheet
- How the PreProcessVariables Table is used in the Configuration sheet
- Sample Commerce Configuration Sheet Examples
- Adding Event Hooks in Configuration sheet for custom functionality
- How to Configure the Synthetic Test Data Configuration Control Sheet
-
-
-
-
-
- The UI Recorder
- Test Modeller – Maintenance
- Test Modeller Core (Linux) Optional – Postgres LDAP
- Test Modeller Core (Linux) Optional – SSL Certificate Installation
- Test Modeller Core (Linux) Optional – Active Directory
- Test Modeller Core (Linux) Installation
- Test Modeller: Software Pre-requisites
- Test Modeller : Installation components
- Test Modeller : System requirements (Windows, Linux)
-
-
-
-
-
-
- Common Problems
- Extend Test Modeller (Advanced)
- Edit Code Templates (Advanced)
- Import existing framework / custom page objects (Advanced)
- Execute Tests (Java)
- Generate Automation Code
- Build a Model (Java)
- Scan an Existing Web App
- Configuration (Java)
- Prerequisites (Selenium Java)
- Welcome Selenium (Java)
-
-
-
-
- Generate Optimised Test Cases and Data into Excel
- Implement Naming Conventions
- Page Object Generation
- Intelligent Page Objects
- Customising Page Objects
- Import Custom Code Snippets
- Rule-Based Test Generation
- Trigger Automation Execution from within Test Modeller
- Automation Configuration
- Test Data Automation for Gherkin Specifications
-
-