Skip to content

Commit 303af72

Browse files
committed
Adding some more tests
1 parent 2e29bc0 commit 303af72

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

core-api/src/test/java/com/optimizely/ab/notification/DecisionNotificationTest.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.optimizely.ab.notification;
1919

20+
import com.optimizely.ab.OptimizelyRuntimeException;
2021
import com.optimizely.ab.bucketing.FeatureDecision;
2122
import com.optimizely.ab.config.FeatureVariable;
2223
import com.optimizely.ab.config.Variation;
@@ -119,4 +120,78 @@ public void testGetDecisionInfo() {
119120
assertEquals(FeatureDecision.DecisionSource.ROLLOUT.toString(), actualFeatureVariableDecisionInfo.get(DecisionNotification.FeatureVariableDecisionNotificationBuilder.SOURCE));
120121
assertEquals(rolloutSourceInfo.get(), actualFeatureVariableDecisionInfo.get(DecisionNotification.FeatureVariableDecisionNotificationBuilder.SOURCE_INFO));
121122
}
123+
124+
@Test(expected = OptimizelyRuntimeException.class)
125+
public void nullTypeFailsExperimentNotificationBuild() {
126+
DecisionNotification.newExperimentDecisionNotificationBuilder()
127+
.withExperimentKey(EXPERIMENT_KEY)
128+
.build();
129+
}
130+
131+
@Test(expected = OptimizelyRuntimeException.class)
132+
public void nullExperimentKeyFailsExperimentNotificationBuild() {
133+
DecisionNotification.newExperimentDecisionNotificationBuilder()
134+
.withType(NotificationCenter.DecisionNotificationType.AB_TEST.toString())
135+
.build();
136+
}
137+
138+
@Test(expected = OptimizelyRuntimeException.class)
139+
public void nullSourceFailsFeatureNotificationBuild() {
140+
DecisionNotification.newFeatureDecisionNotificationBuilder()
141+
.withFeatureKey(FEATURE_KEY)
142+
.withFeatureEnabled(FEATURE_ENABLED)
143+
.build();
144+
}
145+
146+
@Test(expected = OptimizelyRuntimeException.class)
147+
public void nullFeatureKeyFailsFeatureNotificationBuild() {
148+
DecisionNotification.newFeatureDecisionNotificationBuilder()
149+
.withFeatureEnabled(FEATURE_ENABLED)
150+
.withSource(FeatureDecision.DecisionSource.ROLLOUT)
151+
.build();
152+
}
153+
154+
@Test(expected = OptimizelyRuntimeException.class)
155+
public void nullFeatureEnabledFailsFeatureNotificationBuild() {
156+
DecisionNotification.newFeatureDecisionNotificationBuilder()
157+
.withFeatureKey(FEATURE_KEY)
158+
.withSource(FeatureDecision.DecisionSource.ROLLOUT)
159+
.build();
160+
}
161+
162+
@Test(expected = OptimizelyRuntimeException.class)
163+
public void nullFeatureKeyFailsFeatureVariableNotificationBuild() {
164+
DecisionNotification.newFeatureVariableDecisionNotificationBuilder()
165+
.withFeatureEnabled(Boolean.TRUE)
166+
.withVariableKey(FEATURE_VARIABLE_KEY)
167+
.withVariableType(FeatureVariable.VariableType.STRING)
168+
.build();
169+
}
170+
171+
@Test(expected = OptimizelyRuntimeException.class)
172+
public void nullFeatureEnabledFailsFeatureVariableNotificationBuild() {
173+
DecisionNotification.newFeatureVariableDecisionNotificationBuilder()
174+
.withFeatureKey(FEATURE_KEY)
175+
.withVariableKey(FEATURE_VARIABLE_KEY)
176+
.withVariableType(FeatureVariable.VariableType.STRING)
177+
.build();
178+
}
179+
180+
@Test(expected = OptimizelyRuntimeException.class)
181+
public void nullVariableKeyFailsFeatureVariableNotificationBuild() {
182+
DecisionNotification.newFeatureVariableDecisionNotificationBuilder()
183+
.withFeatureKey(FEATURE_KEY)
184+
.withFeatureEnabled(Boolean.TRUE)
185+
.withVariableType(FeatureVariable.VariableType.STRING)
186+
.build();
187+
}
188+
189+
@Test(expected = OptimizelyRuntimeException.class)
190+
public void nullVariableTypeFailsFeatureVariableNotificationBuild() {
191+
DecisionNotification.newFeatureVariableDecisionNotificationBuilder()
192+
.withFeatureKey(FEATURE_KEY)
193+
.withFeatureEnabled(Boolean.TRUE)
194+
.withVariableKey(FEATURE_VARIABLE_KEY)
195+
.build();
196+
}
122197
}

0 commit comments

Comments
 (0)