public Builder put(Identity identity) { if (identity != null) { builder.putAll(identity.computeAttributes().values); } return this; }
@POST @Path("/identity/attributes") public Map<String, Object> computeAttributes(@Valid IdentityDto request) { final Identity identity = ensureExists(mapper.fromDto(request, Identity.class)); return identity.computeAttributes(); }
/** * Returns all active treatments for all active experiments for an identity, taking overrides into account */ 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; }
/** * Returns the current active treatment for an experiment name and identity, taking overrides into account */ public Treatment getActiveTreatment(String experimentName, Identity identity) { strategy.onCacheRead(experimentName, context); final Experiment experiment = cache.getActiveExperiments().get(experimentName); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); if (experiment == null || !experiment.getFilter().evaluate(attributes)) { return null; } return getTreatmentWithOverrides(experiment, identity, attributes); }
doReturn(AttributesMap.empty()).when(identity).computeAttributes(); final Experiment obj5 = experiments.getActiveTreatments(identity).keySet().iterator().next();