Since: API Level v2
public final class

DataGenPlugin

com.webmbt.plugin.DataGenPlugin

Class Overview

Contains a collection of data generation functions to generate various types of test data.

Copyright © 2008 - 2017 TestOptimal LLC. All Rights Reserved.

Summary

Public Constructors
DataGenPlugin()
Public Methods
String camelCase(String inString_p)
uppercase the first char of each word@return
String lowerCase(String inString_p)
lowercase the string passed in

Example: $lowCase('AbC')

@return
String randBinomial(String... params)
returns a random number from a Binomial distribution with n and p specified.
boolean randBoolByDist(String... strings)
To generate a boolean true/false from a random distribution specified with a threshold value to evaluate to true/false.
String randEmail(String... params)
return an email of the specified length from a list of email domain specified.
String randExponential(String... params)
returns a random number from an Exponential distribution with lambda specified.
String randFromDataSet(String dsID_p, String fieldName_p)
returns the value for the field selected from a randomly selected row from the dataset specified.
String randFromList(String list_p)
returns the value for the list of values supplied.
String randFromList(String list_p, String delimiter_p)
returns the value for the list of values supplied.
String randGamma(String... params)
returns a random number from a Gamma distribution with alpha and lambda specified.
String randNormal(String... params)
returns a random number from a normal (gaussian) distribution with mean and stddev specified.
String randPhone(String ptn_p)
return a phone number of specified pattern.
String randPoisson(String... params)
returns a random number from a Poisson distribution with mean specified.
String randState()
return a US state name.
String randStateCode()
return a US state code.
String randStreetAddr()
return a street address.
String randString(String minCharNum_p, String maxCharNum_p)
generate a random alphanumeric (a-z, A-Z, 0-9) string with length between the ranges specified.
String randString(String pattern_p)
generate a random string using the pattern specified.
String randWord(String minChar_p, String maxChar_p, String cap_p)
generate a random word with option of uppercase, lowercase or uppercase on a specific char.
String randWordList(String numWord_p, String minChar_p, String maxChar_p)
returns a list of words with each word in the specified range in length separated by space.
String randZip()
return a us zip code between 00000 - 99999.
String randZipPlus4()
return a US ZIP+4

Example $randZipPlus4()

@return
void shuffleDataSet(String dataSetID_p)
shuffle dataset rows for random retrieval.@return
String upperCase(String inString_p)
uppercase the string passed in

Example: $upperCase('abc')

@return

Public Constructors

public DataGenPlugin ()

Since: API Level v2

Public Methods

public String camelCase (String inString_p)

Since: API Level v2

uppercase the first char of each word@return

Throws
Exception

public String lowerCase (String inString_p)

Since: API Level v2

lowercase the string passed in

Example: $lowCase('AbC')

@return

Throws
Exception

public String randBinomial (String... params)

Since: API Level v2

returns a random number from a Binomial distribution with n and p specified. The return string is formated with the number of precision digits after the decimal point.@return

Throws
Exception
Exception

public boolean randBoolByDist (String... strings)

Since: API Level v2

To generate a boolean true/false from a random distribution specified with a threshold value to evaluate to true/false.

Example: $randBoolByDist('1.5', 'randNormal', '5', '3') to generate a boolean according to normal distribution: true for value <= 1.5 and false for value > 1.5.

Returns
  • boolean
Throws
Exception
Exception

public String randEmail (String... params)

Since: API Level v2

return an email of the specified length from a list of email domain specified. @return

Throws
Exception

public String randExponential (String... params)

Since: API Level v2

returns a random number from an Exponential distribution with lambda specified. The return string is formated with the number of precision digits after the decimal point.@return

Throws
Exception
Exception

public String randFromDataSet (String dsID_p, String fieldName_p)

Since: API Level v2

returns the value for the field selected from a randomly selected row from the dataset specified.

Example $randFromDataSet('ds1','f2') to return the value for column 'f2' from a randomly selected row in data set 'ds1'.

@return

Parameters
dsID_p dataset id
fieldName_p name of the field
Throws
Exception
Exception

public String randFromList (String list_p)

Since: API Level v2

returns the value for the list of values supplied. List is separated by "|" or ";" (check | first then ;).

Example: $randFromList('string1|string2|string3') to randomly return any of the three strings specified.

@return

Parameters
list_p list of values separated by |.
Throws
Exception
Exception

public String randFromList (String list_p, String delimiter_p)

Since: API Level v2

returns the value for the list of values supplied. List is separated by the specified delimiter.

Example: $randFromList('string1,string2,string3',',') to randomly return any of the three strings specified.

@return

Parameters
list_p list of values separated by the specified deliimiter.
delimiter_p delimiter to be used to split the value list supplie in list_p
Throws
Exception

public String randGamma (String... params)

Since: API Level v2

returns a random number from a Gamma distribution with alpha and lambda specified. The return string is formated with the number of precision digits after the decimal point.@return

Throws
Exception
Exception

public String randNormal (String... params)

Since: API Level v2

returns a random number from a normal (gaussian) distribution with mean and stddev specified. The return string is formated with the number of precision digits after the decimal point. If invalid number is passed for mean or stddev, they will be defaulted to 0 for mean and 1.0 for stddev. To return an integer, specify 0 for the precisionDigit param.

Example: $randNormal('20','5.0','2') to generate a number from the normal distribution with mean of 20 and standard deviation of 5.0. The number will have two digits after the decimal point.@return

Throws
Exception
Exception

public String randPhone (String ptn_p)

Since: API Level v2

return a phone number of specified pattern.

Exammple:

  • $randPhone('999-999-9999')
  • $randPhone('(999)-999-9999')
  • $randPhone('999-9999')

Parameters
ptn_p phone number pattern using "9" for each number and "-" to insert a "-" to the phone number.
Returns
  • phone number
Throws
Exception

public String randPoisson (String... params)

Since: API Level v2

returns a random number from a Poisson distribution with mean specified. The return string is formated with the number of precision digits after the decimal point. If invalid mean is passed in, it will be defaulted to 0.0. Example: $randPoisson('5','0) to generate an poisson integer number with mean time between arrival of 5.@return

Throws
Exception
Exception

public String randState ()

Since: API Level v2

return a US state name.

Example: $randState()

@return

Throws
Exception

public String randStateCode ()

Since: API Level v2

return a US state code.

Example: $randStateCode()

@return

Throws
Exception

public String randStreetAddr ()

Since: API Level v2

return a street address.

Example: $randStreetAddr()

@return

Throws
Exception

public String randString (String minCharNum_p, String maxCharNum_p)

Since: API Level v2

generate a random alphanumeric (a-z, A-Z, 0-9) string with length between the ranges specified.

Example: $randString('2', '3') to generate a random string consisting of 2 or 3 alphanumeric characters.@return

Throws
Exception
Exception

public String randString (String pattern_p)

Since: API Level v2

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: $randString('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.@return

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.
Throws
Exception
Exception

public String randWord (String minChar_p, String maxChar_p, String cap_p)

Since: API Level v2

generate a random word with option of uppercase, lowercase or uppercase on a specific char.

Example:

  • $randWord('5','10','UP') to return a word with length between 5 chars to 10 chars in all uppercase.
  • $randWord('5','10','aA') to return a word with uppercase in the second char.
  • $randWord('5','10','A') to return a word with uppercase in the first char.

@return

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.
Throws
Exception

public String randWordList (String numWord_p, String minChar_p, String maxChar_p)

Since: API Level v2

returns a list of words with each word in the specified range in length separated by space.

Example $randWordList('10','3','8') to generate 10 words list with each word between 3 and 8 chars in length.

Parameters
numWord_p number of words to be returned
minChar_p minimum length of each word
maxChar_p maximum length of each word
Throws
Exception

public String randZip ()

Since: API Level v2

return a us zip code between 00000 - 99999.

Example $randZip()

@return

Throws
Exception

public String randZipPlus4 ()

Since: API Level v2

return a US ZIP+4

Example $randZipPlus4()

@return

Throws
Exception

public void shuffleDataSet (String dataSetID_p)

Since: API Level v2

shuffle dataset rows for random retrieval.@return

Throws
MBTException

public String upperCase (String inString_p)

Since: API Level v2

uppercase the string passed in

Example: $upperCase('abc')

@return

Throws
Exception