ParameterizedSampler implements SamplerFunction<P> { public static <P> Builder<P> newBuilder() { return new Builder<>(); } ParameterizedSampler(Builder<P> builder); static Builder<P> newBuilder(); @Override @Nullable Boolean trySample(P parameters); @Deprecated SamplingFlags sample(@Nullable P parameters); @Deprecated static ParameterizedSampler<P> create(List<? extends Rule<P>> rules);  }
@Test public void putAllRules() { Matcher<Void> one = v -> false; Matcher<Void> two = v -> true; Matcher<Void> three = v -> Boolean.FALSE; Matcher<Void> four = v -> Boolean.TRUE; ParameterizedSampler<Void> base = ParameterizedSampler.<Void>newBuilder() .putRule(one, Sampler.ALWAYS_SAMPLE) .putRule(two, Sampler.NEVER_SAMPLE) .putRule(three, Sampler.ALWAYS_SAMPLE) .build(); ParameterizedSampler<Void> extended = ParameterizedSampler.<Void>newBuilder() .putAllRules(base) .putRule(one, Sampler.NEVER_SAMPLE) .putRule(four, Sampler.ALWAYS_SAMPLE) .build(); assertThat(extended).usingRecursiveComparison() .isEqualTo(ParameterizedSampler.<Void>newBuilder() .putRule(one, Sampler.NEVER_SAMPLE) .putRule(two, Sampler.NEVER_SAMPLE) .putRule(three, Sampler.ALWAYS_SAMPLE) .putRule(four, Sampler.ALWAYS_SAMPLE) .build() ); }
@Test public void noRulesOk() { ParameterizedSampler.<Boolean>newBuilder().build(); }