@@ -206,6 +206,75 @@ func (s *CompositeServiceFeatureTestSuite) TestDecisionListenersNotificationWith
206206
207207}
208208
209+ func (s * CompositeServiceFeatureTestSuite ) TestDecisionListenersNotificationWithJSONVariable () {
210+
211+ compositeExperimentService := NewCompositeExperimentService ("" )
212+ compositeFeatureDecisionService := NewCompositeFeatureService ("" , compositeExperimentService )
213+ s .decisionContext .Variable = entities.Variable {
214+ DefaultValue : "{\" field\" : 12.01}" ,
215+ ID : "1" ,
216+ Key : "Key" ,
217+ Type : entities .JSON ,
218+ }
219+
220+ decisionService := & CompositeService {
221+ compositeFeatureService : compositeFeatureDecisionService ,
222+ notificationCenter : registry .GetNotificationCenter ("some_key" ),
223+ }
224+ decisionService .GetFeatureDecision (s .decisionContext , s .testUserContext )
225+
226+ var numberOfCalls = 0
227+ note := notification.DecisionNotification {}
228+ callback := func (notification notification.DecisionNotification ) {
229+ note = notification
230+ numberOfCalls ++
231+ }
232+ id , _ := decisionService .OnDecision (callback )
233+
234+ s .NotEqual (id , 0 )
235+
236+ decisionService .GetFeatureDecision (s .decisionContext , s .testUserContext )
237+ s .Equal (numberOfCalls , 1 )
238+
239+ expectedDecisionInfo := map [string ]interface {}{"feature" : map [string ]interface {}{"featureEnabled" : false , "featureKey" : "my_test_feature_3333" , "source" : FeatureTest ,
240+ "sourceInfo" : map [string ]string {"experimentKey" : "test_experiment_1111" , "variationKey" : "2222" },
241+ "variableKey" : "Key" , "variableType" : entities .JSON , "variableValue" : map [string ]interface {}{"field" : 12.01 }}}
242+
243+ s .Equal (expectedDecisionInfo , note .DecisionInfo )
244+
245+ }
246+
247+ func (s * CompositeServiceFeatureTestSuite ) TestDecisionListenersNotificationWithAllVariables () {
248+
249+ compositeExperimentService := NewCompositeExperimentService ("" )
250+ compositeFeatureDecisionService := NewCompositeFeatureService ("" , compositeExperimentService )
251+
252+ decisionService := & CompositeService {
253+ compositeFeatureService : compositeFeatureDecisionService ,
254+ notificationCenter : registry .GetNotificationCenter ("some_key" ),
255+ }
256+ decisionService .GetFeatureDecision (s .decisionContext , s .testUserContext )
257+
258+ var numberOfCalls = 0
259+ note := notification.DecisionNotification {}
260+ callback := func (notification notification.DecisionNotification ) {
261+ note = notification
262+ numberOfCalls ++
263+ }
264+ id , _ := decisionService .OnDecision (callback )
265+
266+ s .NotEqual (id , 0 )
267+
268+ decisionService .GetFeatureDecision (s .decisionContext , s .testUserContext )
269+ s .Equal (numberOfCalls , 1 )
270+
271+ expectedDecisionInfo := map [string ]interface {}{"feature" : map [string ]interface {}{"featureEnabled" : false , "featureKey" : "my_test_feature_3333" , "source" : FeatureTest ,
272+ "sourceInfo" : map [string ]string {"experimentKey" : "test_experiment_1111" , "variationKey" : "2222" }}}
273+
274+ s .Equal (expectedDecisionInfo , note .DecisionInfo )
275+
276+ }
277+
209278func (s * CompositeServiceFeatureTestSuite ) TestDecisionListenersNotificationWithWrongTypelVariable () {
210279
211280 compositeExperimentService := NewCompositeExperimentService ("" )
0 commit comments