Story

A tester needs to use real data from tables in two databases as part of their test data. This data then needs to be blended with synthetically generated test data to test a reward program. 


The following data will need to be obtained from the databases by configuring Test Data Queries: 

  • address
  • city
  • state
  • zip code
  • reward level


Two Test Data Queries will need to be created to obtain the required real data from these databases. The reward level will then be used within a Test Data Rule to assign a specific credit card prefix for each customer within the generated test data. 


Actors

  • Project (or Project Version) - The Project or Project Version determines what Domains and Attributes will be used for the Test Data Query.

  • Test Data Query - The configuration for performing an SQL query on each database to obtain real data for test data generation. This query may be downloaded and ran with a Scenario, Scenario Chain, or Scenario Chain Set.


Setup Overview

Data will need to be obtained from these databases and tables by performing a query:  

  • Customer Database - Customer table and Address table
  • Reward Database -  Reward table


The testing team requires the following data Attributes for secure customer test data: 

  • Synthetic Data - id, firstName, lastName, birthDate, ssn
  • Real Data - address, city, state, zipCode

Additionally, a synthetically generated credit card requires a specific prefix based on this reward criteria. The reward level will be used to assign the required credit card prefix for each customer:


if reward.level == "Gold"
   then prefix starts with 264444
if reward.level == "Silver"
   then prefix starts with 264445
if reward.level == "Bronze"
   then prefix starts with 264446
else prefix starts with 2644467


For this example, 2 Test Data Queries will need to be defined:

  • Address - Retrieves the customer's real address, city, state, and zip code.

  • Reward - Retrieves the reward level from the Reward database. This value will be used to calculate the appropriate credit card prefix for each customer.


The diagram below shows how the real and synthetic test data will be combined:

  • Green - Synthetic Test Data
  • Blue - Real Data


Test Data Query 1: Address

The first Test Data Query will query the Customer database for this data: 

  • address
  • city
  • state
  • zip code


Step 1: Add a Test Data Query to the Project 

  • Select the appropriate Project within the Project Dashboard of the GenRocket web platform.

  • Use the Filter input field or scroll up/down to locate the Project. Click on the Project Name to select it.


  • Expand the Manage Menu option for the appropriate Project Version and then select Test Data Queries.


  • Click on Add Test Data Query.


  • Enter a Name and Description (Optional) for the Test Data Query.

  • Select Query Before for the type and click Save to finish.


  • The new Test Data Query will appear in the table as shown below:


Step 2: Configure Parameters

  • For this example, the following parameters have been configured: 
    • resourcePath* - #{resource.output.directory}
    • resourceSubDir - customer
    • resourceName* - config.properties
    • grvar1 - #{Customer.id}

  • Click Save after the query has been entered to save the change.


Step 3: Enter the Query

A query will need to be entered to obtain the customer address information.

  • The following query has been entered for the Address Test Data Query:
    select address, city, state, zip_code
    from address
    where customer_id = grVar1

  • Click Save after the query has been entered to save the change.


Step 4: Add Domains, Attributes & Columns

A Domain Attribute will need added to the Test Data Query configuration for each data column. These Attributes are used for reading the obtained real data values.

Each Domain, Attribute, and Column will need to be added to the Test Data Query. Queried data will be populated for these Attributes: 

  • address
  • city
  • state
  • zip code


Note: Repeat these steps 4 times to add this information for each Domain Attribute: 

  • Click on Add to select a Domain and Attribute.


  • Select the Domain and Attribute from each drop-down menu.

  • Enter a Column Name for the data. Click Save to finish.


  • The table will appear as below once all Domain Attributes have been added:


Test Data Query 2: Reward

The second Test Data Query will query the Reward database for this data: 

  • reward level


Step 1: Add a Test Data Query to the Project 

  • Click on Add Test Data Query to add another query.


  • Enter a Name and Description (Optional) for the Test Data Query.

  • Select Query Each as the type and click Save to finish.


  • The new Test Data Query will appear in the table as shown below:



Step 2: Configure Parameters

  • For this example, the following parameters have been configured: 
    • resourcePath* - #{resource.output.directory}
    • resourceSubDir - reward
    • resourceName* - config.properties
    • grvar1 - #{Customer.id}

  • Click Save after the query has been entered to save the change.


Step 3: Enter the Query

A query will need to be entered to obtain the reward level information.

  • The following query has been entered for the Reward Test Data Query:
    select reward_level
    from reward
    where customer_id = grVar1


  • Click Save after the query has been entered to save the change.


Step 4: Add Domains, Attributes & Columns

A Domain Attribute will need added to the Test Data Query configuration for each data column. These Attributes are used for reading the obtained real data values. Each Domain, Attribute, and Column will need to be added to the Test Data Query. 


Queried data will be populated for this Attribute: rewardLevel.

  • Click on Add to select a Domain and Attribute.




  • Select the Domain and Attribute from each drop-down menu.

  • Enter a Column Name for the data.


Download the Test Data Query and Scenario

Next, the Test Data Queries will need to be downloaded and run with a Scenario, Chain, or Chain Set. For this example a Scenario will be used.

  • Click on the Download (Cloud) option located on the far right of the table in the Actions Column to download it to your local computer.


  • Click on the Download (Cloud) option within the Scenario section of the Project Dashboard to download it to your local computer.


Run the Test Data Query with the Scenario

The Test Data Query and the Scenario (or Scenario Chain/Scenario Chain Set) are ran using the command line shown at the bottom of the screen. 


This command can be copied and pasted into a CMD or Terminal Window and modified accordingly.



The following is an example of the command line for running this example's Address Test Data Query with a Scenario.



These values will be different depending on the name of the Test Data Query and the Scenario to be run.

  • AddressQueries.gtdq - Name of the Test Data Query to be run.
  • <ScenarioName.grs> - Name of the Scenario, Scenario Chain, or Scenario Chain Set to run.


Open a CMD or Terminal Window and set the directory to where files are downloaded from the GenRocket web platform to your local computer. The following images show the command line in a CMD window.



Then replace the appropriate values within the command line. The Test Data Query and Scenario Name can be changed accordingly. 



Generated Test Data

The generated data would appear similar to what is shown below: