Skip to content

Commit f2ce3aa

Browse files
Sampel json parset test done for holdout
1 parent 714de6d commit f2ce3aa

File tree

3 files changed

+188
-5
lines changed

3 files changed

+188
-5
lines changed

core-api/src/main/java/com/optimizely/ab/config/ExperimentCore.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public interface ExperimentCore extends IdKeyMapped {
3939
List<TrafficAllocation> getTrafficAllocation();
4040
Map<String, Variation> getVariationKeyToVariationMap();
4141
Map<String, Variation> getVariationIdToVariationMap();
42-
Map<String, String> getUserIdToVariationKeyMap();
4342

4443
default String serializeConditions(Map<String, String> audiencesMap) {
4544
Condition condition = this.getAudienceConditions();

core-api/src/test/java/com/optimizely/ab/config/ValidProjectConfigV4.java

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,106 @@ public class ValidProjectConfigV4 {
547547
DatafileProjectConfigTestUtils.createListOfObjects(
548548
new TrafficAllocation(
549549
"327323",
550-
100
550+
500
551551
)
552552
),
553-
Collections.<String>emptyList(),
554-
Collections.<String>emptyList(),
553+
null,
554+
null,
555555
""
556556
);
557+
558+
private static final Holdout HOLDOUT_ZERO_TRAFFIC_HOLDOUT = new Holdout(
559+
"1007532345428",
560+
"holdout_zero_traffic",
561+
Holdout.HoldoutStatus.RUNNING.toString(),
562+
Collections.<String>emptyList(),
563+
null,
564+
DatafileProjectConfigTestUtils.createListOfObjects(
565+
VARIATION_HOLDOUT_VARIATION_OFF
566+
),
567+
DatafileProjectConfigTestUtils.createListOfObjects(
568+
new TrafficAllocation(
569+
"327323",
570+
0
571+
)
572+
),
573+
null,
574+
null,
575+
""
576+
);
577+
578+
private static final Holdout HOLDOUT_INCLUDED_FLAGS_HOLDOUT = new Holdout(
579+
"1007543323427",
580+
"holdout_included_flags",
581+
Holdout.HoldoutStatus.RUNNING.toString(),
582+
Collections.<String>emptyList(),
583+
null,
584+
DatafileProjectConfigTestUtils.createListOfObjects(
585+
VARIATION_HOLDOUT_VARIATION_OFF
586+
),
587+
DatafileProjectConfigTestUtils.createListOfObjects(
588+
new TrafficAllocation(
589+
"327323",
590+
2000
591+
)
592+
),
593+
DatafileProjectConfigTestUtils.createListOfObjects(
594+
"4195505407",
595+
"3926744821",
596+
"3281420120"
597+
),
598+
null,
599+
""
600+
);
601+
602+
private static final Holdout HOLDOUT_EXCLUDED_FLAGS_HOLDOUT = new Holdout(
603+
"100753234214",
604+
"holdout_excluded_flags",
605+
Holdout.HoldoutStatus.RUNNING.toString(),
606+
Collections.<String>emptyList(),
607+
null,
608+
DatafileProjectConfigTestUtils.createListOfObjects(
609+
VARIATION_HOLDOUT_VARIATION_OFF
610+
),
611+
DatafileProjectConfigTestUtils.createListOfObjects(
612+
new TrafficAllocation(
613+
"327323",
614+
1500
615+
)
616+
),
617+
null,
618+
DatafileProjectConfigTestUtils.createListOfObjects(
619+
"2591051011",
620+
"2079378557",
621+
"3263342226"
622+
),
623+
""
624+
);
625+
626+
private static final Holdout HOLDOUT_TYPEDAUDIENCE_HOLDOUT = new Holdout(
627+
"10075323429",
628+
"typed_audience_holdout",
629+
Holdout.HoldoutStatus.RUNNING.toString(),
630+
DatafileProjectConfigTestUtils.createListOfObjects(
631+
AUDIENCE_BOOL_ID,
632+
AUDIENCE_INT_ID,
633+
AUDIENCE_INT_EXACT_ID,
634+
AUDIENCE_DOUBLE_ID
635+
),
636+
AUDIENCE_COMBINATION,
637+
DatafileProjectConfigTestUtils.createListOfObjects(
638+
VARIATION_HOLDOUT_VARIATION_OFF
639+
),
640+
DatafileProjectConfigTestUtils.createListOfObjects(
641+
new TrafficAllocation(
642+
"327323",
643+
1000
644+
)
645+
),
646+
Collections.<String>emptyList(),
647+
Collections.<String>emptyList(),
648+
""
649+
);
557650
private static final String LAYER_TYPEDAUDIENCE_EXPERIMENT_ID = "1630555627";
558651
private static final String EXPERIMENT_TYPEDAUDIENCE_EXPERIMENT_ID = "1323241597";
559652
public static final String EXPERIMENT_TYPEDAUDIENCE_EXPERIMENT_KEY = "typed_audience_experiment";
@@ -1543,7 +1636,11 @@ public static ProjectConfig generateValidProjectConfigV4_holdout() {
15431636

15441637
// list holdouts
15451638
List<Holdout> holdouts = new ArrayList<Holdout>();
1639+
holdouts.add(HOLDOUT_ZERO_TRAFFIC_HOLDOUT);
1640+
holdouts.add(HOLDOUT_INCLUDED_FLAGS_HOLDOUT);
15461641
holdouts.add(HOLDOUT_BASIC_HOLDOUT);
1642+
holdouts.add(HOLDOUT_TYPEDAUDIENCE_HOLDOUT);
1643+
holdouts.add(HOLDOUT_EXCLUDED_FLAGS_HOLDOUT);
15471644

15481645
// list featureFlags
15491646
List<FeatureFlag> featureFlags = new ArrayList<FeatureFlag>();

core-api/src/test/resources/config/holdouts-project-config.json

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,57 @@
475475
}
476476
],
477477
"holdouts": [
478+
{
479+
"audienceIds": [],
480+
"id": "1007532345428",
481+
"key": "holdout_zero_traffic",
482+
"status": "Running",
483+
"trafficAllocation": [
484+
{
485+
"endOfRange": 0,
486+
"entityId": "327323"
487+
}
488+
],
489+
"variations": [
490+
{
491+
"featureEnabled": false,
492+
"id": "$opt_dummy_variation_id",
493+
"key": "ho_off_key"
494+
}
495+
]
496+
},
497+
{
498+
"audienceIds": [],
499+
"id": "1007543323427",
500+
"key": "holdout_included_flags",
501+
"status": "Running",
502+
"trafficAllocation": [
503+
{
504+
"endOfRange": 2000,
505+
"entityId": "327323"
506+
}
507+
],
508+
"variations": [
509+
{
510+
"featureEnabled": false,
511+
"id": "$opt_dummy_variation_id",
512+
"key": "ho_off_key"
513+
}
514+
],
515+
"includedFlags": [
516+
"4195505407",
517+
"3926744821",
518+
"3281420120"
519+
]
520+
},
478521
{
479522
"audienceIds": [],
480523
"id": "10075323428",
481524
"key": "basic_holdout",
482525
"status": "Running",
483526
"trafficAllocation": [
484527
{
485-
"endOfRange": 100,
528+
"endOfRange": 500,
486529
"entityId": "327323"
487530
}
488531
],
@@ -493,6 +536,50 @@
493536
"key": "ho_off_key"
494537
}
495538
]
539+
},
540+
{
541+
"id": "10075323429",
542+
"key": "typed_audience_holdout",
543+
"status": "Running",
544+
"trafficAllocation": [
545+
{
546+
"endOfRange": 1000,
547+
"entityId": "327323"
548+
}
549+
],
550+
"variations": [
551+
{
552+
"featureEnabled": false,
553+
"id": "$opt_dummy_variation_id",
554+
"key": "ho_off_key"
555+
}
556+
],
557+
"audienceIds": ["3468206643", "3468206644", "3468206646", "3468206645"],
558+
"audienceConditions" : ["or", "3468206643", "3468206644", "3468206646", "3468206645" ],
559+
},
560+
{
561+
"audienceIds": [],
562+
"id": "100753234214",
563+
"key": "holdout_excluded_flags",
564+
"status": "Running",
565+
"trafficAllocation": [
566+
{
567+
"endOfRange": 1500,
568+
"entityId": "327323"
569+
}
570+
],
571+
"variations": [
572+
{
573+
"featureEnabled": false,
574+
"id": "$opt_dummy_variation_id",
575+
"key": "ho_off_key"
576+
}
577+
],
578+
"excludedFlags": [
579+
"2591051011",
580+
"2079378557",
581+
"3263342226"
582+
]
496583
}
497584
],
498585
"groups": [

0 commit comments

Comments
 (0)