Class TestDataProvider


  • public class TestDataProvider
    extends Object
    • Field Detail

      • LIST_ARRAY_ITEM_COUNT

        protected static final int LIST_ARRAY_ITEM_COUNT
        See Also:
        Constant Field Values
    • Constructor Detail

      • TestDataProvider

        public TestDataProvider()
        This class will invoke classes with random data
      • TestDataProvider

        public TestDataProvider​(Map<String,​Function<String,​Object>> customMap)
        This class will invoke classes with random data from a custom map
        Parameters:
        customMap - The elements in this map will override the keys of the default map
    • Method Detail

      • getDefaultProviderMap

        public static Map<String,​Function<String,​Object>> getDefaultProviderMap()
        This method defines the default functions which generate random values for the corresponding classes
        Returns:
        A map with key (string), (value(Function<String, Object>))
      • fill

        public <T> T fill​(Class c,
                          String seed,
                          boolean tryComplexConstructorIfPossible)
        This method will try to invoke the provided class.
        Type Parameters:
        T - Return type
        Parameters:
        c - The class which should be invoked
        seed - The seed which should be used to generate the constructor parameters
        tryComplexConstructorIfPossible - If true, try largest constructor first
        Returns:
        Initialized object
      • generateTestDataByNonStandardClass

        protected <T> T generateTestDataByNonStandardClass​(Class c,
                                                           String seed,
                                                           boolean complex)
      • fillMutableWithNull

        public <T> T fillMutableWithNull​(Class c)
                                  throws IllegalAccessException,
                                         InvocationTargetException
        This method will initialize the provided class with null pointer for the mutable variables and random values for the immutable variables (can't be null)
        Type Parameters:
        T - Return type
        Parameters:
        c - Class which should be initialized
        Returns:
        Initialized class
        Throws:
        IllegalAccessException - is thrown if the access to the class, field, method or constructor is not allowed.
        InvocationTargetException - is thrown when the called method throws an exception.