8 Synthetic Data
Learn about Oracle Communications Solution Test Automation Platform (STAP) Synthetic Data generation.
Topics in this chapter:
STAP Synthetic Data Generation
Overview
Synthetic Data Generator is a critical component of a test automation platform, designed to produce diverse, scalable, and high-quality data for testing applications. It eliminates the reliance on real-world data by generating customizable data sets that emulate production-like conditions, ensuring comprehensive test coverage and improving testing efficiency.
- Internal plugins handle various data types, including numeric, alphanumeric, and text.
- External plugins connect with third-party providers, with the currently supported plugin being the Data Faker plugin, which integrates with Data Faker.
For more information, see https://www.datafaker.net/.
Configuration
Synthetic Data Generation plugins are assigned or configured with attribute data configuration which are used in STAP BDD automation. To configure and utilize synthetic data generation plugins within the STAP BDD automation framework, perform the following steps:
- Configure the attribute home location in
config.properties.
Add property in ${WORKSPACE}/config/config.properties file. For more details see, Configuration Folder.
attributeData.home=${WORKSPACE}/config/attributeData
- Add attribute data configuration properties files in ${WORKSPACE}/config/attributeData directory. Each configuration file name should end with "-attributeData.properties".
- In BDD, use the attribute values in Table 8-1 to retrieve next and current value:
Table 8-1 Synthetic Data Syntax
Value | Description | Syntax | Example |
---|---|---|---|
get Next Value | Computes the next value based on configuration and generates a new value |
@{<attributeName>} or @{<attributeName>.nextValue} |
@{mobileNumber} or @{mobileNumber.nextValue} |
get Current Value | Retrieves the current generated value. | @{<attributeName>.currentValue} |
@{mobileNumber.currentValue} |
Plugin with External Generators
For more information on External Generators, refer to Fake Data Plugin.
Plugin with Internal Generators
Number Generation
Table 8-2 describes Unique Number Generation type, its properties, and runtime BDD:
Table 8-2 Unique Number Generation Table
Type | Description | Properties | Runtime BDD |
---|---|---|---|
NUMBER_UNIQUE_BOUND | number is bound in range of [startValue, endValue) |
mobileNumber1-attributeData.properties
|
number_unique_bound.scenario
|
NUMBER_UNIQUE_INFINITE | number has startValue and no endValue. Infinite values are generated | mobileNumber2-attributeData.properties
|
number_unique_infinite.scenario
|
NUMBER_UNIQUE_DIGITS | number has startValue and no endValue. Number of digits in the value is specified. | mobileNumber3-attributeData.properties
|
number_unique_digits.scenario
|
NUMBER_UNIQUE_VALUES | number has startValue and no endValue. Number of values generated is specified. | mobileNumber4-attributeData.properties
|
number_unique_values.scenario
|
Random Number Generation
Table 8-3 decribes Randome Number Generation types, its properties, and runtime BDD:
Table 8-3 Random Number Generation
Type | Description | Properties | Runtime BDD |
---|---|---|---|
NUMBER_RANDOM_VALUES | random number; arguments passed are minimum_value and maximum_value; number is bound in range of [minimum_value, maximum_value) |
randomNumber1-attributeData.properties
|
|
NUMBER_RANDOM_DIGITS | random number; arguments passed are minimum_digits and maximum_digits |
randomNumber2-attributeData.properties
|
|
Text Generation
Table 8-4 describes Text Generation types, its properties, and runtime BDD:
Table 8-4 Text Generation Table
Type | Description | Properties | Runtime bdd |
---|---|---|---|
TEXT_INIT_UPPER | Initial letter is uppercase, remaining letters are lower case |
text1-attributeData.properties
|
text_init_upper.scenario
|
TEXT_LOWER | All letters of the string are in lowercase |
text2-attributeData.properties
|
text_lower.scenario
|
TEXT_UPPER | All letters of the string are in uppercase |
ttext3-attributeData.properties
|
text_upper.scenario
|
TEXT_ALPHANUMERIC | Initial character of the string is a letter, remaining are alphanumeric characters |
text4-attributeData.properties
|
text_alphanumeric.scenario
|
TEXT_ALPHANUMERIC_SPECIAL | Initial character of the string is a letter, remaining are alphanumeric and special characters |
text5-attributeData.properties
|
text_alphanumeric_special.scenario
|
Unique ID Generation
Table 8-5 describes Unique ID Generation type, its properties, and runtime BDD:
Table 8-5 Unique ID Generation table
Type | Description | Properties | Runtime BDD |
---|---|---|---|
UNIQUE_ALPHABETIC | All characters are letters |
uniqueID1-attributeData.properties
|
unique_alphabetic.scenario
|
UNIQUE_ALPHANUMERIC | Random no. of letters and digits in the text; Initial character is a letter |
uniqueID2-attributeData.properties
|
|
UNIQUE_ALPHANUMERIC_SPECIAL | Random no. of letters, digits and, special characters in the text; Initial character is a letter |
uniqueID3-attributeData.properties
|
unique_alphanumeric_special.scenario
|
UNIQUE_FIRST_DIGITS | First x-characters are digits, rest are letters |
uniqueID4-attributeData.properties
|
unique_first_digits.scenario
|
Fake Data Generation
Datafaker is a library for Java and Kotlin to generate fake data. This is helpful when generating test data to fill a database, to generate data for a stress test, or anonymize data from production services.
STAP leverages data faker 2.4.2 (current or latest) and creates a plugin to use it to generate fake data for automation scenarios. It also supports the output in multiple languages.
For more information on Fake Data Plugin, see Data Faker Resource and Data Faker Github.
Table 8-6 lists the Supported Generator or methods:
Table 8-6 Supported Generator or Methods
Providers | Attributes |
---|---|
name | fullName, firstName, lastName, femaleFirstName, malefirstName, nameWithMiddle, prefix, suffix, title,username |
internet | emailAddress, domainName, username, getIpV6Address |
address | city, streetName, zipCode, buildingNumber, cityPrefix, citySuffix, country, countryCode, countyByZipCode, fullAddress, latitude, longitude, postcode, secondaryAddress, state, stateAbbr, zipCode, timeZone |
number | randomNumber, digits, randomDouble, numberBetween, negative, positive, digit, randomDigitNotZero |
timeAndDate | future, past,birthday |
phoneNumber | phoneNumber, cellPhone, phoneNumberNational, subscriberNumber, extension |
word | noun, preposition, conjunction, adverb, adjective,interjection, verb |
text | text, lowercaseCharacter, uppercaseCharacter |
barcode | gtin14 |
currency | name |
subscription | paymentMethods, paymentTerms, statuses,subscriptionTerms |
unique | fetchFromYaml |
idNumber | idNumber |
Configuration
To generate fake data, select the provider and corresponding attribute from the Data Faker Library Documentations mentioned in Table 8-7:
Table 8-7 Data Faker Library Documentations
property key | value (eg) | description |
---|---|---|
name | fakeData | Name of the attribute Data should be fakeData. |
description | Fake data generator | Any short description. |
plugin | DataFakerPlugin | Plugin name should be DataFakerPlugin. |
type | collection | Should be the same value for pluginManager to recognize. |
list | email,Double,Number,future | Enter comma separated custom named list of all the keys to be used in the case file for the scenarios. |
<List> [n1] email [n2] firstName. . . . [n n] Double |
internet.emailAddress firstName=name.fullName |
Enter each of the keys entered in the list and in values the corresponding provider and its attribute to be used to generate random data. Format: <key_name_provided_in_list> =
<data_faker_provider>.<data_faker_attribute>(comma_separated_params/custom_values_to_be_passed_in_attribute) For example, list=Double Double=number.randomDouble(2,500,700) (the configuration is intended to generate a double upto two decimal places between 500 to 700) |
locale | in ,ar | The language the output is expected in. |
Ensure the src/main/java/com/oracle/cagbu/stap/data/plugins/datafaker/validMethods.properties file supports the entry in attributeData.properties configuration. For more information, see Data Faker Resource .
The following is an example attributeData.properties File:
# Attribute Name
name=fakeData
# Short description
description=Fake data generator
#Plugin associated with the attribute
plugin=DataFakerPlugin
type=collection
# enter the list of methods to be used
list=emailAddress,ip,phoneNumber,fullName,discount,billcharge,dataPlan,future,past,accessKey,networkName,barcode,currency
# enter the key as the method for each of the keys from the above list and corresponding provider and attribute name as per data faker documentation
emailAddress=internet.emailAddress
ip=internet.getIpV6Address
phoneNumber=phoneNumber.phoneNumber
fullName=name.fullName
discount=number.numberBetween(1,5)
billcharge=number.randomDouble(2,500,700)
dataPlan=subscription.subscriptionTerms
future=timeAndDate.future
past=timeAndDate.past
accessKey=text.text(10,26,true,true,true)
networkName=word.noun
barcode=barcode.gtin14
currency=currency.name
# language to be used to generate data
locale=in
Fake Data Usage
Refer to the following format to invoke and use data faker plugin in a scenario case files:
| variable | @{$<key_mentioned_in_attributeData.properties_file>.<METHOD>} |
example:
Data:
| name | @{$firstName.currentValue} |
| name | @{$firstName.nextValue} |
| name | @{$firstName} |
Table 8-8 lists the methods supported.
Table 8-8 Methods Supported
METHOD | EXPECTED OUTPUT |
---|---|
currentValue |
outputs the current value if there is no previously generated value, calls nextValue |
nextValue | output is a newly generated value |
<empty> | defaults to nextValue |
Fake Data Generation Example
Example 1:
The following example shows how to generate and store random data using a variable-based approach:
Case: DataFaker
When set variable, generating random email addresses
Save:
| emailID1 | @{$emailAddress.currentValue} |
| emailID2 | @{$emailAddress.nextValue} |
| emailID3 | @{$emailAddress} |
When set variable, generating random ip addresses
Save:
| ipAddress1 | @{$ip.nextValue} |
| ipAddress2 | @{$ip} |
When set variable, generating random phone numbers
Save:
| mobile1 | @{$phoneNumber.nextValue} |
| mobile2 | @{$phoneNumber} |
When set variable, generating random service agent names
Save:
| agentname1 | @{$fullName.nextValue} |
| agentname2 | @{$fullName} |
When set variable, generating random discount percentages
Save:
| discount1 | @{$discount.nextValue} |
| discount2 | @{$discount} |
When set variable, generating random billing charges
Save:
| billing1 | @{$billcharge.nextValue} |
| billing2 | @{$billcharge} |
When set variable, generating random data plans
Save:
| dataplan1 | @{$dataPlan.nextValue} |
| dataplan2 | @{$dataPlan} |
When set variable, generating random expiry dates
Save:
| date1 | @{$future.nextValue} |
| date2 | @{$future} |
When set variable, generating random previous expiry dates
Save:
| expdate1 | @{$past.nextValue} |
| expdate2 | @{$past} |
When set variable, generating random access keys
Save:
| access1 | @{$accessKey.nextValue} |
| access2 | @{$accessKey} |
When set variable, generating random network names
Save:
| network1 | @{$networkName.nextValue} |
| network2 | @{$networkName} |
When set variable, generating random bar codes
Save:
| barcode1 | @{$barcode.nextValue} |
| barcode2 | @{$barcode} |
When set variable, generating random currencies
Save:
| currency1 | @{$currency.nextValue} |
| currency2 | @{$currency} |
Saving Synthetic Data into a Variable(Release 1.25.1.1.0 or later)
You can save the synthetic data generated using a data faker into a variable for further use. For instance, when generating IP addresses dynamically, the next generated IP value can be stored in a predefined variable for easy reference and reuse.
ipAddress1 = $ip.nextValue
Here, $ip.nextValue
represents the next generated IP address, which
is then stored in the variable ipAddress1
. This allows the saved
value to be used in subsequent operations or references within the application.
And set variable, assign account name value to a variable
Save: | uniqueAccountName | ${accountName} |
And validate account name exists, in Siebel regardless of whether the status code is 200 or 404
Data: | $query | searchspec=([Name] = "${accountName}") |
Validate: | $status |
$IGNORE_STATUS_VALIDATION |
And validate account name exists, in Siebel and execute the loop until the status is 200 and
generate account name using Data Faker
RepeatWhile: | ${response.status} | 200 |
Data: | $query | searchspec=([Name] = "${accountName}")
| Validate: | $status | $IGNORE_STATUS_VALIDATION |
Save: | uniqueAccountName | ${accountName} |
| firstName | @{$firstName} | | lastName | @{$lastName} | | accountName | %CONCAT(${firstName},
,${lastName}) |
And set variable, to save the account name which will be used to create account in Siebel
Save: | accountName | ${uniqueAccountName} |
Save:
| uniqueAccountName | ${accountName} |
| firstName | @{$firstName} |
| lastName | @{$lastName} |
| accountName | %CONCAT(${firstName}, ,${lastName}) |