8000 [FSSDK-11448] Java Implementation: Add Experiment ID and Variation ID to Decision Notification by esrakartalOpt · Pull Request #566 · optimizely/java-sdk · GitHub
[go: up one dir, main page]

Skip to content
8000

[FSSDK-11448] Java Implementation: Add Experiment ID and Variation ID to Decision Notification #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
Fix decision test
  • Loading branch information
esrakartalOpt committed May 1, 2025
commit 332b87f48f327dc43a41a20fefc071794055c30c
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public class DecisionNotificationTest {

private static final Boolean FEATURE_ENABLED = Boolean.FALSE;
private static final String EXPERIMENT_KEY = "experimentKey";
private static final String EXPERIMENT_ID = "1234567";
private static final String FEATURE_KEY = "featureKey";
private static final String FEATURE_VARIABLE_KEY = "featureVariableKey";
private static final String FEATURE_TEST = "featureTest";
private static final String FEATURE_TEST_VARIATION = "featureTestVariation";
private static final String USER_ID = "userID";
private static final Map<String, String> USER_ATTRIBUTES = Collections.singletonMap("user", "attr");
private static final Variation VARIATION = mock(Variation.class);
private static final String VARIATION_ID = "1234567";

private FeatureTestSourceInfo featureTestSourceInfo;
private RolloutSourceInfo rolloutSourceInfo;
Expand All @@ -58,6 +60,8 @@ public void setUp() {
.withAttributes(USER_ATTRIBUTES)
.withExperimentKey(EXPERIMENT_KEY)
.withVariation(VARIATION)
.withExperimentId(EXPERIMENT_ID)
.withVariationId(VARIATION_ID)
.withType(NotificationCenter.DecisionNotificationType.AB_TEST.toString())
.build();
featureTestSourceInfo = new FeatureTestSourceInfo(FEATURE_TEST, FEATURE_TEST_VARIATION);
Expand Down Expand Up @@ -107,6 +111,8 @@ public void testGetDecisionInfo() {
HashMap<String, String> expectedExperimentDecisionInfo = new HashMap<>();
expectedExperimentDecisionInfo.put(Decision 7AB7 Notification.ExperimentDecisionNotificationBuilder.EXPERIMENT_KEY, EXPERIMENT_KEY);
expectedExperimentDecisionInfo.put(DecisionNotification.ExperimentDecisionNotificationBuilder.VARIATION_KEY, VARIATION.getKey());
expectedExperimentDecisionInfo.put(DecisionNotification.ExperimentDecisionNotificationBuilder.EXPERIMENT_ID, EXPERIMENT_ID);
expectedExperimentDecisionInfo.put(DecisionNotification.ExperimentDecisionNotificationBuilder.VARIATION_ID, VARIATION_ID);
assertEquals(expectedExperimentDecisionInfo, experimentDecisionNotification.getDecisionInfo());

// Assert for Feature's DecisionInfo
Expand All @@ -128,7 +134,7 @@ public void testGetDecisionInfo() {

@Test
public void testToString() {
assertEquals("DecisionNotification{type='ab-test', userId='userID', attributes={user=attr}, decisionInfo={experimentKey=experimentKey, variationKey=null}}", experimentDecisionNotification.toString());
assertEquals("DecisionNotification{type='ab-test', userId='userID', attributes={user=attr}, decisionInfo={experimentKey=experimentKey, variationKey=null, experimentId='1234567', variationId='1234567'}}", experimentDecisionNotification.toString());
assertEquals("DecisionNotification{type='feature', userId='userID', attributes={user=attr}, decisionInfo={featureEnabled=false, sourceInfo={experimentKey=featureTest, variationKey=featureTestVariation}, source=feature-test, featureKey=featureKey}}", featureDecisionNotification.toString());
assertEquals("DecisionNotification{type='feature-variable', userId='userID', attributes={user=attr}, decisionInfo={variableType=string, featureEnabled=true, sourceInfo={}, variableValue=null, variableKey=featureVariableKey, source=rollout, featureKey=featureKey}}", featureVariableDecisionNotification.toString());
}
Expand Down
Loading
0