diff options
Diffstat (limited to 'src/main/java/org/junit/experimental/theories/ParameterSupplier.java')
-rw-r--r-- | src/main/java/org/junit/experimental/theories/ParameterSupplier.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/main/java/org/junit/experimental/theories/ParameterSupplier.java b/src/main/java/org/junit/experimental/theories/ParameterSupplier.java index 9016c91..bac8b34 100644 --- a/src/main/java/org/junit/experimental/theories/ParameterSupplier.java +++ b/src/main/java/org/junit/experimental/theories/ParameterSupplier.java @@ -2,7 +2,42 @@ package org.junit.experimental.theories; import java.util.List; - +/** + * Abstract parent class for suppliers of input data points for theories. Extend this class to customize how {@link + * org.junit.experimental.theories.Theories Theories} runner + * finds accepted data points. Then use your class together with <b>@ParametersSuppliedBy</b> on input + * parameters for theories. + * + * <p> + * For example, here is a supplier for values between two integers, and an annotation that references it: + * + * <pre> + * @Retention(RetentionPolicy.RUNTIME) + * <b>@ParametersSuppliedBy</b>(BetweenSupplier.class) + * public @interface Between { + * int first(); + * + * int last(); + * } + * + * public static class BetweenSupplier extends <b>ParameterSupplier</b> { + * @Override + * public List<<b>PotentialAssignment</b>> getValueSources(<b>ParameterSignature</b> sig) { + * List<<b>PotentialAssignment</b>> list = new ArrayList<PotentialAssignment>(); + * Between annotation = (Between) sig.getSupplierAnnotation(); + * + * for (int i = annotation.first(); i <= annotation.last(); i++) + * list.add(<b>PotentialAssignment</b>.forValue("ints", i)); + * return list; + * } + * } + * </pre> + * </p> + * + * @see org.junit.experimental.theories.ParametersSuppliedBy + * @see org.junit.experimental.theories.Theories + * @see org.junit.experimental.theories.FromDataPoints + */ public abstract class ParameterSupplier { - public abstract List<PotentialAssignment> getValueSources(ParameterSignature sig); + public abstract List<PotentialAssignment> getValueSources(ParameterSignature sig) throws Throwable; } |