Class RandPlugin

java.lang.Object
com.testoptimal.exec.plugin.RandPlugin

public final class RandPlugin extends Object
Contains a collection of data generation functions to generate various types of test data using pattern and random number generator.
Author:
yxl01
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    email(int minChar_p, int maxChar_p, String[] domainList_p)
    return an email of the specified length from a list of email domain specified.
    fromList(String[] list_p)
    returns the value for the list of values supplied.
    int
    number(int startInt_p, int endInt_p)
    returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
    phone(String pattern_p)
    return a phone number of specified pattern.
    return a US state code.
    return a US state name.
    return a street address.
    string(int minCharNum_p, int maxCharNum_p)
    generate a random alphanumeric (a-z, A-Z, 0-9) string with length between the ranges specified.
    stringPattern(String pattern_p)
    generate a random string using the pattern specified.
    word(int minChar_p, int maxChar_p, String cap_p)
    generate a random word with option of uppercase, lowercase or uppercase on a specific char.
    return a US zip code between 00000 - 99999.
    return a US ZIP+4

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandPlugin

      public RandPlugin()
  • Method Details

    • number

      public int number(int startInt_p, int endInt_p)
      returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
      Parameters:
      startInt_p - min value inclusive
      endInt_p - max value exlusive
    • stringPattern

      public String stringPattern(String pattern_p)
      generate a random string using the pattern specified. 'a' for one lower case letter, 'A' for one uppercase letter, '9' for one 0-9 digit, '*' for any one alphanumeric letter. All other chars are inserted literally and returned.

      Example: stringPattern('aaaAA99.99') to generate 3 lower case letters followed by 2 upper case letter followed by 2 digits of numbers then a period and finally 2 digits of numbers, like xyzAB12.20.

      Parameters:
      pattern_p - a for a lower case letter, A for uppercase letter, 9 for numbers, other chars are treated as static char and inserted in the return string as they appear.
    • string

      public String string(int minCharNum_p, int maxCharNum_p)
      generate a random alphanumeric (a-z, A-Z, 0-9) string with length between the ranges specified.
      Parameters:
      minChartNum_p - minimum # of characters to generate the random string
      maChartNum_p - maximum # of characters to generate the random string
      Returns:
    • fromList

      public String fromList(String[] list_p)
      returns the value for the list of values supplied.
      Parameters:
      list_p - String array of list of strings to be selected randomly
      Returns:
    • word

      public String word(int minChar_p, int maxChar_p, String cap_p)
      generate a random word with option of uppercase, lowercase or uppercase on a specific char. Example:
      • word('5','10','UP') to return a word with length between 5 chars to 10 chars in all uppercase.
      • word('5','10','aA') to return a word with uppercase in the second char.
      • word('5','10','A') to return a word with uppercase in the first char.
      Parameters:
      minChar_p - minimum length for the word
      maxChar_p - maximum length for the word
      cap_p - UP for upercase, LO for lowercase, pattern "aAa" for word starts with lower case and upercase at the second char and the rest in lowercase.
      Returns:
    • email

      public String email(int minChar_p, int maxChar_p, String[] domainList_p)
      return an email of the specified length from a list of email domain specified.
      Parameters:
      minChar_p - minimum length of the email name to the left of "@"
      maxChar_p - maximum length of the email name to the left of "@"
      domainList_p - a list of email domain (like .com, .gov, .edu, etc.) separated by comma, if specify blank value, it defaults to "com,net,edu,gov,biz,au,cn,ca,co.uk,co.in.
      Returns:
    • phone

      public String phone(String pattern_p)
      return a phone number of specified pattern.
      Parameters:
      ptn_p - phone number pattern using "9" for each number and "-" to insert a "-" to the phone number.
      Returns:
    • zipCode

      public String zipCode()
      return a US zip code between 00000 - 99999.
      Returns:
    • zipCodePlus4

      public String zipCodePlus4()
      return a US ZIP+4
      Returns:
    • streetAddr

      public String streetAddr()
      return a street address.
      Returns:
    • stateUS

      public String stateUS()
      return a US state name.
      Returns:
    • stateCodeUS

      public String stateCodeUS()
      return a US state code.
      Returns: