Package de.a9d3.testing.testdata
Class TestDataProvider
- java.lang.Object
-
- de.a9d3.testing.testdata.TestDataProvider
-
public class TestDataProvider extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static intLIST_ARRAY_ITEM_COUNT
-
Constructor Summary
Constructors Constructor Description TestDataProvider()This class will invoke classes with random dataTestDataProvider(Map<String,Function<String,Object>> customMap)This class will invoke classes with random data from a custom map
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tfill(Class c, String seed, boolean tryComplexConstructorIfPossible)This method will try to invoke the provided class.<T> TfillMutableWithNull(Class c)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)protected <T> TgenerateTestDataByNonStandardClass(Class c, String seed, boolean complex)static Map<String,Function<String,Object>>getDefaultProviderMap()This method defines the default functions which generate random values for the corresponding classes
-
-
-
Field Detail
-
LIST_ARRAY_ITEM_COUNT
protected static final int LIST_ARRAY_ITEM_COUNT
- See Also:
- Constant Field Values
-
-
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 invokedseed- The seed which should be used to generate the constructor parameterstryComplexConstructorIfPossible- 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.
-
-