Additional feature to pre-determine children list to clone
This commit is contained in:
1 parent
21df2d0bd2
commit
a33604b498
10 files changed
+267
-37
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user