junit-quickcheck
junit-quickcheck copied to clipboard
Is there a way to configure `per-From` GeneratorParameters?
Consider a case when multiple @From are used:
public class GeneratorDescriptors {
@From(value = KnownManifestKeyGenerator.class, frequency = 10)
@Regex("[-_a-zA-Z0-9]+")
@From(value = RegexStringGenerator.class, frequency = 40)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface ManifestKey {
}
public final HashMap<@ManifestKey String, String> manifestAttributes = null;
}
So far so good.
However what if I would like to put two @From(value = RegexStringGenerator.class, frequency = 40) instances?
Then it would be kind of problematic to assign two @RegExp instances.
The same goes for "two @Size" case and so on. How quickcheck would know which regexp configures which generator?
In case you wondered, meta-meta does not help:
public class GeneratorDescriptors {
@Regex("[a-z]+")
@From(value = RegexStringGenerator.class, frequency = 90)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
@interface RegExp1 {
}
@Regex("[A-Z]+")
@From(value = RegexStringGenerator.class, frequency = 40)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
@interface RegExp2 {
}
@RegExp1
@RegExp2
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface ManifestKey {
}
public final HashMap<@ManifestKey String, @RegExp1 String> manifestAttributes = null;
}
I'm not sure "annotation programming" is the way to go here, however it would be really nice if something could be made around that case.
It would probably make sense if "the closest" Regex annotation was resolved for each generator.