Package net.morimekta.testing
Class DataProviderUtil
- java.lang.Object
-
- net.morimekta.testing.DataProviderUtil
-
public class DataProviderUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object[][]
buildDataDimensions(java.util.List<?>... dimensions)
This is a utility to be used withjunit-dataprovider
.
-
-
-
Method Detail
-
buildDataDimensions
public static java.lang.Object[][] buildDataDimensions(java.util.List<?>... dimensions)
This is a utility to be used withjunit-dataprovider
. It will instead of taking in an array of argument arrays, will get an array of available dimensions, each with possible values. It will then multiply all the possible dimension possibilities with each other and result the array of parameter array thatjunit-dataprovider
wants.E.g. providing two dimensions, content type and locale, e.g. like this:
Will create 6 argument arrays, one for each combination of content type and locale as if the input was this:return buildDataDimensions( Arrays.asList(ContentType.WALLPAPER, ContentType.AUDIO), Arrays.asList(Locale.US, Locale.DE, Locale.SIMPLIFIED_CHINESE));
This can significantly shorten the argument list especially with larger set of dimensions and longer lists of options for each. It accepts null values and does not accept empty dimensions. Each dimension is called a 'layer' in the input.return new Object[][]{ {ContentType.WALLPAPER, Locale.US}, {ContentType.WALLPAPER, Locale.DE}, {ContentType.WALLPAPER, Locale.SIMPLIFIED_CHINESE}, {ContentType.AUDIO, Locale.US}, {ContentType.AUDIO, Locale.DE}, {ContentType.AUDIO, Locale.SIMPLIFIED_CHINESE}, });
- Parameters:
dimensions
- The available dimensions.- Returns:
- The argument arrays.
-
-