Package dev.aherscu.qa.testing.utils
Class RandomUtils
- java.lang.Object
-
- dev.aherscu.qa.testing.utils.RandomUtils
-
@ThreadSafe public final class RandomUtils extends Object
Random utilities.- Author:
- aherscu
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_RANDOM_STRING_LENGTH
The default random string length.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
lastRandomAlphaNumeric(String template)
Fills a provided template with the last random value generated on current thread.static String
padRandomAlphaNumeric(String template, int length)
Fills a provided template with a random value such that the entire length of the returned string is as specified.static String
randomAlphaNumeric(String template)
Fills a provided template with a random value.static String
randomAlphaNumeric(String template, int randomStringLength)
Fills a provided template with a random value.
-
-
-
Field Detail
-
DEFAULT_RANDOM_STRING_LENGTH
public static final int DEFAULT_RANDOM_STRING_LENGTH
The default random string length.- See Also:
- Constant Field Values
-
-
Method Detail
-
lastRandomAlphaNumeric
public static String lastRandomAlphaNumeric(String template)
Fills a provided template with the last random value generated on current thread.- Parameters:
template
- string template into which to insert the last random value; seeMessageFormat
- Returns:
- the template filled with the last random value, or
StringUtils.EMPTY
if no such value exists
-
padRandomAlphaNumeric
public static String padRandomAlphaNumeric(String template, int length)
Fills a provided template with a random value such that the entire length of the returned string is as specified.- Parameters:
template
- string template into which to insert a random value; seeMessageFormat
length
- the desired length of the returned string- Returns:
- the template filled with a
RandomStringUtils.randomAlphanumeric(int)
- Throws:
IllegalArgumentException
- if the desired length is less that the length of the template filled with an empty string
-
randomAlphaNumeric
public static String randomAlphaNumeric(String template)
Fills a provided template with a random value.- Parameters:
template
- string template into which to insert a random value; seeMessageFormat
- Returns:
- the template filled with a
RandomStringUtils.randomAlphanumeric(int)
-
randomAlphaNumeric
public static String randomAlphaNumeric(String template, int randomStringLength)
Fills a provided template with a random value.- Parameters:
template
- string template into which to insert a random value; seeMessageFormat
randomStringLength
- the random string length- Returns:
- the template filled with a
RandomStringUtils.randomAlphanumeric(int)
- Throws:
IllegalArgumentException
- if the randomStringLength is negative
-
-