Class 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 datatype
      static java.lang.String generateTitle​(AutoGenerateDataType dataType)
      Returns a title using Faker based on the passed in datatype
      static java.lang.String offsetDateTime​(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties)
      Returns a date based on the parameters passed in
      static java.lang.String randomString​(AutoGenerateDataType dataType, int len)
      Returns a randomly generated string based on the dataType passed in
      static java.lang.String setDOB​(java.lang.String autoGenerateDataParameter, FastRunProperties fastRunProperties)
      Returns a date using the passed in parameters
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DataGenerator

        public DataGenerator()
    • 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 - The AutoGenerateDataType that will be used to generate a random string
        len - 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
        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