40 lines
1.8 KiB
OpenEdge ABL
40 lines
1.8 KiB
OpenEdge ABL
/**
|
|
* @description This is a class that provides utility methods for test classes
|
|
*/
|
|
public class TestCloneUtility {
|
|
/**
|
|
* @description This method will generate a string that is a certain length. Optionally, you can determine if the string will include numbers, or if the string will consist of numeric characters only. The option to consist of numeric characters only overrides the option of including numeric characters in the string characters.
|
|
* @param stringLength (Integer) Length of String
|
|
* @param includeNumbers (Boolean) Option to include numbers
|
|
* @param numbersOnly (Boolean) Option to only post numbers
|
|
* @return (String) Randomly Generated String
|
|
*/
|
|
static public String GenerateRandomString(Integer stringLength, Boolean includeNumbers, Boolean numbersOnly) {
|
|
String returnString = '';
|
|
String characterBucket = '';
|
|
String stringBucket = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ';
|
|
String numericBucket = '123456789';
|
|
characterBucket += stringBucket;
|
|
if(includeNumbers){
|
|
characterBucket += numericBucket;
|
|
}
|
|
if(numbersOnly){
|
|
characterBucket = numericBucket;
|
|
}
|
|
//now lets start to generate the String
|
|
while (returnString.length() < stringLength) {
|
|
Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), characterBucket.length());
|
|
returnString += characterBucket.substring(idx, idx+1);
|
|
}
|
|
return returnString;
|
|
}
|
|
/**
|
|
* @description Generate a random string with wordly characters
|
|
* @param (Integer) stringLength;
|
|
* @return (String) random string
|
|
*/
|
|
static public String GenerateRandomString(Integer stringLength){
|
|
return GenerateRandomString(stringLength, false, false);
|
|
}
|
|
}
|