|
51 | 51 | import org.mockito.junit.MockitoJUnit;
|
52 | 52 | import org.mockito.junit.MockitoRule;
|
53 | 53 |
|
54 |
| -import com.fasterxml.jackson.annotation.JsonFormat; |
55 | 54 | import com.optimizely.ab.Optimizely;
|
56 | 55 | import com.optimizely.ab.OptimizelyDecisionContext;
|
57 | 56 | import com.optimizely.ab.OptimizelyForcedDecision;
|
|
80 | 79 | import static com.optimizely.ab.config.ValidProjectConfigV4.HOLDOUT_BASIC_HOLDOUT;
|
81 | 80 | import static com.optimizely.ab.config.ValidProjectConfigV4.HOLDOUT_EXCLUDED_FLAGS_HOLDOUT;
|
82 | 81 | import static com.optimizely.ab.config.ValidProjectConfigV4.HOLDOUT_INCLUDED_FLAGS_HOLDOUT;
|
| 82 | +import static com.optimizely.ab.config.ValidProjectConfigV4.HOLDOUT_TYPEDAUDIENCE_HOLDOUT; |
83 | 83 | import static com.optimizely.ab.config.ValidProjectConfigV4.ROLLOUT_2;
|
84 | 84 | import static com.optimizely.ab.config.ValidProjectConfigV4.ROLLOUT_3_EVERYONE_ELSE_RULE;
|
85 | 85 | import static com.optimizely.ab.config.ValidProjectConfigV4.ROLLOUT_3_EVERYONE_ELSE_RULE_ENABLED_VARIATION;
|
@@ -1355,4 +1355,30 @@ public void excludedFlagsHoldoutAppliesToAllExceptSpecified() {
|
1355 | 1355 |
|
1356 | 1356 | logbackVerifier.expectMessage(Level.INFO, "User (user123) is in variation (ho_off_key) of holdout (holdout_excluded_flags).");
|
1357 | 1357 | }
|
| 1358 | + |
| 1359 | + @Test |
| 1360 | + public void userMeetsHoldoutAudienceConditions() { |
| 1361 | + ProjectConfig holdoutProjectConfig = generateValidProjectConfigV4_holdout(); |
| 1362 | + |
| 1363 | + Bucketer mockBucketer = new Bucketer(); |
| 1364 | + |
| 1365 | + DecisionService decisionService = new DecisionService(mockBucketer, mockErrorHandler, null); |
| 1366 | + |
| 1367 | + Map<String, Object> attributes = new HashMap<>(); |
| 1368 | + attributes.put("$opt_bucketing_id", "ppid543400"); |
| 1369 | + attributes.put("booleanKey", true); |
| 1370 | + attributes.put("integerKey", 1); |
| 1371 | + |
| 1372 | + FeatureDecision featureDecision = decisionService.getVariationForFeature( |
| 1373 | + FEATURE_FLAG_BOOLEAN_FEATURE, |
| 1374 | + optimizely.createUserContext("user123", attributes), |
| 1375 | + holdoutProjectConfig |
| 1376 | + ).getResult(); |
| 1377 | + |
| 1378 | + assertEquals(HOLDOUT_TYPEDAUDIENCE_HOLDOUT, featureDecision.experiment); |
| 1379 | + assertEquals(VARIATION_HOLDOUT_VARIATION_OFF, featureDecision.variation); |
| 1380 | + assertEquals(FeatureDecision.DecisionSource.HOLDOUT, featureDecision.decisionSource); |
| 1381 | + |
| 1382 | + logbackVerifier.expectMessage(Level.INFO, "User (user123) is in variation (ho_off_key) of holdout (typed_audience_holdout)."); |
| 1383 | + } |
1358 | 1384 | }
|
0 commit comments