Package com.qcefast.util
Class DataGenerator
- java.lang.Object
-
- com.qcefast.util.DataGenerator
-
public class DataGenerator extends java.lang.Object
This class is used to aid the FAST framework in generating data- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description DataGenerator()
-
Method Summary
Modifier and Type Method Description static java.lang.String
generateName(AutoGenerateDataType dataType)
Returns a name using Faker based on the passed in datatypestatic java.lang.String
generateTitle(AutoGenerateDataType dataType)
Returns a title using Faker based on the passed in datatypestatic java.lang.String
offsetDateTime(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties)
Returns a date based on the parameters passed instatic java.lang.String
randomString(AutoGenerateDataType dataType, int len)
Returns a randomly generated string based on the dataType passed instatic java.lang.String
setDOB(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties)
Returns a date using the passed in parameters
-
-
-
Method Detail
-
randomString
public static java.lang.String randomString(AutoGenerateDataType dataType, int len)
Returns a randomly generated string based on the dataType passed in- Parameters:
dataType
- TheAutoGenerateDataType
that will be used to generate a random stringlen
- The length the random string will be- Returns:
- A randomly generated string
- Since:
- 1.0.0
-
offsetDateTime
public static java.lang.String offsetDateTime(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties) throws FastException
Returns a date based on the parameters passed in- Parameters:
autoGenerateDataParameter
- - parameters that will be used to offset a date
Usage:- "{timeperiod1}={offset1}::{timeperiod2}={offset2}...{timeperiod5}={offset5}" - Example: if current time is 2021-05-12T09:15:24, DAY=-2::HOUR=3, will yield 2021-05-10T12:15:24
- TimePeriods:
- YEAR
- MONTH
- DAY
- HOUR
- MINUTE
- SECOND
fastRunProperties
- The properties a teststep is being run with- Returns:
- A string date time in yyyy-MM-ddTHH:mm:ss format
- Throws:
FastException
- - if an error occurs during execution- Since:
- 1.0.0
-
setDOB
public static java.lang.String setDOB(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties) throws FastException
Returns a date using the passed in parameters- Parameters:
autoGenerateDataParameter
- - parameters that will be used to set a date of birth
Usage:- autoGenerateDataParameter=
- "RANDOM" - generates a random date using range 0 to 99 in yyyy-MM-dd format
- "{minAge}{delimiter}{maxAge}" - generates a date using the specified ages. Example usage: 5::39, assuming the delimiter was ::, would generate a random date that is sometime between 5 years, and 39 years before the current date
- "{age}" - generates a random date that is between {age} + 1 years ago and yesterday. For ex: {age}=0 will generate a random date between 1 year ago and yesterday
- null or "" - will return the current date in yyyy-MM-dd format
- autoGenerateDataParameter=
fastRunProperties
- - The properties a teststep is being run with- Returns:
- A date of birth in yyyy-MM-dd format
- Throws:
FastException
- If an error occurs during execution- Since:
- 1.0.0
-
generateName
public static java.lang.String generateName(AutoGenerateDataType dataType) throws FastException
Returns a name using Faker based on the passed in datatype- Parameters:
dataType
- TheAutoGenerateDataType
that will be used to generate a name. Refer to the specific enum value inAutoGenerateDataType
for usage- Returns:
- The generated name
- Throws:
FastException
- If an error occurs during execution- Since:
- 1.0.0
-
generateTitle
public static java.lang.String generateTitle(AutoGenerateDataType dataType) throws FastException
Returns a title using Faker based on the passed in datatype- Parameters:
dataType
- TheAutoGenerateDataType
that will be used to generate a name. Refer to the specific enum value inAutoGenerateDataType
for usage- Returns:
- A title
- Throws:
FastException
- If an error occurs during execution- Since:
- 1.0.0
-
-