public class Cases extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Cases.EightCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,OUTPUT> |
static interface |
Cases.FiveCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,OUTPUT> |
static interface |
Cases.FourCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,OUTPUT> |
static interface |
Cases.NineCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,INPUT9,OUTPUT> |
static interface |
Cases.SevenCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,OUTPUT> |
static interface |
Cases.SixCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,OUTPUT> |
static interface |
Cases.ThreeCaseCompositionFunction<INPUT1,INPUT2,INPUT3,OUTPUT> |
static interface |
Cases.TwoCaseCompositionFunction<INPUT1,INPUT2,OUTPUT> |
| Constructor and Description |
|---|
Cases() |
| Modifier and Type | Method and Description |
|---|---|
static <INPUT,OUTPUT> |
compose(Case<INPUT> baseCase,
BiFunction<Random,INPUT,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the subcases of the given base case.
|
static <OUTPUT> Case<OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case[] baseCases,
BiFunction<Random,Object[],OUTPUT> composition)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,INPUT9,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Case<INPUT5> baseCase5,
Case<INPUT6> baseCase6,
Case<INPUT7> baseCase7,
Case<INPUT8> baseCase8,
Case<INPUT9> baseCase9,
Cases.NineCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,INPUT9,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Case<INPUT5> baseCase5,
Case<INPUT6> baseCase6,
Case<INPUT7> baseCase7,
Case<INPUT8> baseCase8,
Cases.EightCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Case<INPUT5> baseCase5,
Case<INPUT6> baseCase6,
Case<INPUT7> baseCase7,
Cases.SevenCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Case<INPUT5> baseCase5,
Case<INPUT6> baseCase6,
Cases.SixCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Case<INPUT5> baseCase5,
Cases.FiveCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,INPUT4,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Case<INPUT4> baseCase4,
Cases.FourCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,INPUT3,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Case<INPUT3> baseCase3,
Cases.ThreeCaseCompositionFunction<INPUT1,INPUT2,INPUT3,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <INPUT1,INPUT2,OUTPUT> |
compose(CaseCompositionMode caseCompositionMode,
Case<INPUT1> baseCase1,
Case<INPUT2> baseCase2,
Cases.TwoCaseCompositionFunction<INPUT1,INPUT2,OUTPUT> compositionFunction)
Creates and returns a new case that is "composed" of the values returned by a collection of base cases, according
to a composition function.
|
static <T,U> Case<U> |
map(Case<T> original,
BiFunction<Random,T,U> mapping) |
static <T,U> Case<U> |
map(Case<T> original,
Function<T,U> mapping) |
static <T> Case<T> |
of(Subcase<T>... subcases) |
static <T> Case<T> |
of(Supplier<T>... subcases) |
static <T> Case<T> |
of(T... literalCases) |
static <T> Case<T> |
ofDelegates(Supplier<Case<T>>... delegateCases) |
public static <OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case[] baseCases, BiFunction<Random,Object[],OUTPUT> composition)
Use this overload only when you have more base cases than can be covered by one of the type-safe overloads.
This function works by collecting all of the subcases defined by each of the base cases and combining them in order to produce a single "composed" subcase. The composition function is responsible for returning the result of a single such subcase, where the values generated by each of the base cases are provided as input.
For example, consider the following composition:
Case<Integer> composedCase = Cases.compose(
CaseCompositionMode.PAIRWISE_PERMUTATIONS_OF_SUBCASES,
new Case[] { Any.of(2, 3), Any.of(10, 100, 1000) },
(random, values) -> (int)values[0] * (int)values[1]
);
composedCase.generateAllOnce().stream().forEach(System.out::println);
This will return a Case of Integers that is the result of multiplying one of the values from the first base case
(2 or 3) with one of the values from the second base case (10, 100, or
1000). The output might look like the following:
20
200
2000
30
300
3000
OUTPUT - - the return type of the composed case and of the composition function.caseCompositionMode - - the algorithm to use for deciding both how many composed subcases will be created,
as well as which specific values of the base cases to use for each composed subcase. See the descriptions
for the individual algorithms for more information. In general, you should use
CaseCompositionMode.PAIRWISE_PERMUTATIONS_OF_SUBCASES unless you experience performance issues.
Use CaseCompositionMode.EACH_SUBCASE_AT_LEAST_ONCE to limit the total number of composed subcases.baseCases - - the cases that the overall case is comprised of.composition - - a function that produces an OUTPUT value based on the specific values chosen for
each of the subcases. This function is supplied with the random number generator to use for the test as
well as an array of the values generated for each of the base cases in the baseCases array. This
array will have the same length as the baseCases array, and the value at each index i will
have been produced by a subcase of the base case at the same index.public static <INPUT,OUTPUT> Case<OUTPUT> compose(Case<INPUT> baseCase, BiFunction<Random,INPUT,OUTPUT> compositionFunction)
INPUT - the type of values generated by the base case.OUTPUT - the type of values generated by the returned case.baseCase - - the case that provides the basis for the returned case.compositionFunction - - a function that is called once for each subcase defined by the base case. It is
provided with the random number generator to use for the test as well as a value generated by one of the
base case's subcases.public static <INPUT1,INPUT2,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Cases.TwoCaseCompositionFunction<INPUT1,INPUT2,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Cases.ThreeCaseCompositionFunction<INPUT1,INPUT2,INPUT3,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Cases.FourCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Case<INPUT5> baseCase5, Cases.FiveCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Case<INPUT5> baseCase5, Case<INPUT6> baseCase6, Cases.SixCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Case<INPUT5> baseCase5, Case<INPUT6> baseCase6, Case<INPUT7> baseCase7, Cases.SevenCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Case<INPUT5> baseCase5, Case<INPUT6> baseCase6, Case<INPUT7> baseCase7, Case<INPUT8> baseCase8, Cases.EightCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,OUTPUT> compositionFunction)
public static <INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,INPUT9,OUTPUT> Case<OUTPUT> compose(CaseCompositionMode caseCompositionMode, Case<INPUT1> baseCase1, Case<INPUT2> baseCase2, Case<INPUT3> baseCase3, Case<INPUT4> baseCase4, Case<INPUT5> baseCase5, Case<INPUT6> baseCase6, Case<INPUT7> baseCase7, Case<INPUT8> baseCase8, Case<INPUT9> baseCase9, Cases.NineCaseCompositionFunction<INPUT1,INPUT2,INPUT3,INPUT4,INPUT5,INPUT6,INPUT7,INPUT8,INPUT9,OUTPUT> compositionFunction)
@SafeVarargs public static <T> Case<T> of(Subcase<T>... subcases)
@SafeVarargs public static <T> Case<T> of(Supplier<T>... subcases)
@SafeVarargs public static <T> Case<T> of(T... literalCases)
@SafeVarargs public static <T> Case<T> ofDelegates(Supplier<Case<T>>... delegateCases)
public static <T,U> Case<U> map(Case<T> original, BiFunction<Random,T,U> mapping)
Copyright © 2017 Redfin. All rights reserved.