@Test public void testGetActiveTreatments() { final Experiment experiment = mock(Experiment.class); final Identity identity = mock(Identity.class); doReturn(FilterExpression.alwaysTrue()).when(experiment).getFilter(); doReturn(AttributesMap.empty()).when(identity).computeAttributes(); doReturn(ImmutableMap.of("foo", experiment)) .when(cache) .getActiveExperiments(); experiments.getActiveTreatments(identity); verifyZeroInteractions(store); verify(cache).getActiveExperiments(); }
public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; }
Experiments implements Closeable { public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; } }
Experiments implements Closeable { public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; } private  Experiments(ExperimentsStoreProvider provider,
                        CacheStrategy strategy,
                        ExecutorService executorService); }
Experiments implements Closeable { public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; } private  Experiments(ExperimentsStoreProvider provider,
                        CacheStrategy strategy,
                        ExecutorService executorService); static Builder using(ExperimentsStoreProvider provider); Treatment getActiveTreatment(String experimentName, Identity identity); Iterable<Experiment> getActiveExperiments(); Map<Experiment, Treatment> getActiveTreatments(Identity identity); Iterable<Experiment> find(Filter filter); Iterable<Experiment> find(); Experiment get(String experimentName); void delete(String experimentName); void save(Experiment experiment); Experiment create(String name); @Override void close(); }
Experiments implements Closeable { public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; } private  Experiments(ExperimentsStoreProvider provider,
                        CacheStrategy strategy,
                        ExecutorService executorService); static Builder using(ExperimentsStoreProvider provider); Treatment getActiveTreatment(String experimentName, Identity identity); Iterable<Experiment> getActiveExperiments(); Map<Experiment, Treatment> getActiveTreatments(Identity identity); Iterable<Experiment> find(Filter filter); Iterable<Experiment> find(); Experiment get(String experimentName); void delete(String experimentName); void save(Experiment experiment); Experiment create(String name); @Override void close();  }