Class Arranger

java.lang.Object
com.ocadotechnology.gembus.test.Arranger

public class Arranger extends Object
To arrange test data using pseudo random values.
  • Constructor Details

    • Arranger

      public Arranger()
  • Method Details

    • some

      public static <T> T some(Class<T> type, String... excludedFields)
      See Also:
    • some

      public static <T> T some(Class<T> type, Map<String,Supplier<?>> overrides)
      Generate a random instance of the given type.
      Parameters:
      type - the type for which an instance will be generated
      overrides - 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

      public 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. Use some(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 generated
      amount - number of objects to generate
      overrides - 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

      public static <T> Stream<T> someObjects(Class<T> type, int amount, String... excludedFields)
      Generate a random instance of the given type.
      Parameters:
      type - the type for which an instance will be generated
      amount - number of objects to generate
      Returns:
      a random instance of the given type
    • someMatching

      public static <T> T someMatching(Class<T> type, Predicate<T> predicate, String... excludedFields)
      Returns:
      whatever T that satisfies predicate
    • someMatching

      public static <T> T someMatching(T[] array, Predicate<T> predicate)
      Returns:
      whatever array member that satisfies predicate or null if no member satisfies it
    • someEmail

      public static String someEmail()
      Returns:
      whatever (pseudo random) email
    • someText

      public static String 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

      public static String someText(int maxLength)
      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

      public static String someText(int minLength, int maxLength)
      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

      public static String someString()
      Returns:
      whatever string i.e. some(String.class)
    • someString

      public static String someString(int maxLength)
      Returns:
      whatever string i.e. some(String.class), but with length less or equal the maxLength
    • someString

      public static String someString(int minLength, int maxLength)
      Returns:
      whatever string i.e. some(String.class), but with length greater or equal the minLength and less or equal the maxLength
    • somePriceLikeBigDecimal

      public static BigDecimal 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 - inclusive
      maxValue - inclusive
      Returns:
      whatever integer from range [minValue,maxValue]
    • somePositiveInt

      public static int somePositiveInt(Integer boundIncl)
      Parameters:
      boundIncl - non null positive value
      Returns:
      whatever integer from range [1,boundIncl]
    • somePositiveLong

      public static long somePositiveLong(Long boundIncl)
      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 - inclusive
      max - exclusive
    • someDouble

      public static double someDouble()
    • someDouble

      public static double someDouble(double min, double max)
      Parameters:
      min - inclusive
      max - exclusive
    • someFrom

      public static <T> T someFrom(Collection<T> source)
    • someGivenOrLater

      public static LocalDate someGivenOrLater(LocalDate given)
    • someGivenOrEarlier

      public static LocalDate someGivenOrEarlier(LocalDate given)
    • someInstant

      public static Instant someInstant()
    • somePriceLikeBigDecimal

      public static BigDecimal somePriceLikeBigDecimal(BigDecimal min, BigDecimal max)
    • someFirstName

      public static String someFirstName()
    • someLastName

      public static String someLastName()
    • someStringLike

      public static String someStringLike(String regex)