Package com.ocadotechnology.gembus.test
Class Arranger
java.lang.Object
com.ocadotechnology.gembus.test.Arranger
To arrange test data using pseudo random values.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
static <T> T
Generate a random instance of the given type.static boolean
static double
static double
someDouble
(double min, double max) static String
static String
static float
static float
someFloat
(float min, float max) static <T> T
someFrom
(Collection<T> source) static LocalDate
someGivenOrEarlier
(LocalDate given) static LocalDate
someGivenOrLater
(LocalDate given) static Instant
static int
static int
someInteger
(int minValue, int maxValue) static String
static long
someLong()
static <T> T
someMatching
(Class<T> type, Predicate<T> predicate, String... excludedFields) static <T> T
someMatching
(T[] array, Predicate<T> predicate) static <T> Stream<T>
someObjects
(Class<T> type, int amount, String... excludedFields) Generate a random instance of the given type.static <T> Stream<T>
someObjects
(Class<T> type, int amount, Map<String, Supplier<?>> overrides) Generate a random instance of the given type.static int
somePositiveInt
(Integer boundIncl) static long
somePositiveLong
(Long boundIncl) static BigDecimal
static BigDecimal
somePriceLikeBigDecimal
(BigDecimal min, BigDecimal max) static <T> T
someSimplified
(Class<T> type, String... excludedFields) Deprecated.This method creates a lot of complexity resulting in lesser performance and increased memory consumption.static String
static String
someString
(int maxLength) static String
someString
(int minLength, int maxLength) static String
someStringLike
(String regex) static String
someText()
static String
someText
(int maxLength) static String
someText
(int minLength, int maxLength)
-
Constructor Details
-
Arranger
public Arranger()
-
-
Method Details
-
some
-
some
Generate a random instance of the given type.- Parameters:
type
- the type for which an instance will be generatedoverrides
- map of fields that should be overridden. Field name should be used as the key in the map entry while the corresponding value should be a supplier of the value that should be set on the field. Invalid map entries result in error logs, but do not break the object generation process.- Returns:
- a random instance of the given type
-
someSimplified
Deprecated.This method creates a lot of complexity resulting in lesser performance and increased memory consumption. Usesome(Class, String...)
instead.- See Also:
-
EasyRandom.nextObject(java.lang.Class<T>)
-
someObjects
public static <T> Stream<T> someObjects(Class<T> type, int amount, Map<String, Supplier<?>> overrides) Generate a random instance of the given type.- Parameters:
type
- the type for which an instance will be generatedamount
- number of objects to generateoverrides
- map of fields that should be overridden. Field name should be used as the key in the map entry while the corresponding value should be a supplier of the value that should be set on the field. Invalid map entries result in error logs, but do not break the object generation process.- Returns:
- a random instance of the given type
-
someObjects
Generate a random instance of the given type.- Parameters:
type
- the type for which an instance will be generatedamount
- number of objects to generate- Returns:
- a random instance of the given type
-
someMatching
- Returns:
- whatever T that satisfies predicate
-
someMatching
- Returns:
- whatever array member that satisfies predicate or null if no member satisfies it
-
someEmail
- Returns:
- whatever (pseudo random) email
-
someText
- Returns:
- whatever (pseudo-random) text, that looks a bit like a sequence of words; there is a Markov chain trained on English text underneath that generates a sequence of characters
-
someText
- Returns:
- whatever (pseudo-random) text, that looks a bit like a sequence of words; there is a Markov chain trained on English text underneath that generates a sequence of characters
-
someText
- Returns:
- whatever (pseudo-random) text, that looks a bit like a sequence of words; there is a Markov chain trained on English text underneath that generates a sequence of characters
-
someString
- Returns:
- whatever string i.e. some(String.class)
-
someString
- Returns:
- whatever string i.e. some(String.class), but with length less or equal the maxLength
-
someString
- Returns:
- whatever string i.e. some(String.class), but with length greater or equal the minLength and less or equal the maxLength
-
somePriceLikeBigDecimal
- Returns:
- whatever positive BigDecimal with 2 decimal places, i.e. like a price
-
someLong
public static long someLong() -
someInteger
public static int someInteger() -
someInteger
public static int someInteger(int minValue, int maxValue) - Parameters:
minValue
- inclusivemaxValue
- inclusive- Returns:
- whatever integer from range [minValue,maxValue]
-
somePositiveInt
- Parameters:
boundIncl
- non null positive value- Returns:
- whatever integer from range [1,boundIncl]
-
somePositiveLong
- Parameters:
boundIncl
- non null positive value- Returns:
- whatever long from range [1,boundIncl]
-
someBoolean
public static boolean someBoolean() -
someFloat
public static float someFloat() -
someFloat
public static float someFloat(float min, float max) - Parameters:
min
- inclusivemax
- exclusive
-
someDouble
public static double someDouble() -
someDouble
public static double someDouble(double min, double max) - Parameters:
min
- inclusivemax
- exclusive
-
someFrom
-
someGivenOrLater
-
someGivenOrEarlier
-
someInstant
-
somePriceLikeBigDecimal
-
someFirstName
-
someLastName
-
someStringLike
-