@@ -188,7 +188,7 @@ public void testGoodActivationWithListener() {
188188 final Variation [] callbackVariation = new Variation [1 ];
189189
190190 callbackCalled [0 ] = false ;
191- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Activate , new ActivateNotificationListener () {
191+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Activate , new ActivateNotificationListener () {
192192 @ Override
193193 public void onActivate (@ Nonnull Experiment experiment , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Variation variation , @ Nonnull LogEvent event ) {
194194 callbackCalled [0 ] = true ;
@@ -202,13 +202,13 @@ public void onActivate(@Nonnull Experiment experiment, @Nonnull String userId, @
202202 assertEquals (v , callbackVariation [0 ]);
203203 assertEquals (true , callbackCalled [0 ]);
204204 assertEquals (1 , notificationId );
205- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
205+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
206206 }
207207 else {
208208 assertNull (v );
209209 assertEquals (false , callbackCalled [0 ]);
210210 assertEquals (1 , notificationId );
211- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
211+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
212212 }
213213
214214 }
@@ -220,7 +220,7 @@ public void testBadActivationWithListener() {
220220 final boolean [] callbackCalled = new boolean [1 ];
221221
222222 callbackCalled [0 ] = false ;
223- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Activate , new TrackNotificationListener () {
223+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Activate , new TrackNotificationListener () {
224224 @ Override
225225 public void onTrack (@ Nonnull String eventKey , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Map <String , ?> eventTags , @ Nonnull LogEvent event ) {
226226 callbackCalled [0 ] = true ;
@@ -231,7 +231,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M
231231
232232 assertEquals (false , callbackCalled [0 ]);
233233 assertTrue (notificationId <= 0 );
234- assertFalse (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
234+ assertFalse (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
235235
236236 }
237237
@@ -404,7 +404,7 @@ public void testBadTrackWithListener() {
404404 final boolean [] numberOfCalls = new boolean [1 ];
405405 numberOfCalls [0 ]= false ;
406406
407- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Activate ,
407+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Activate ,
408408 new TrackNotificationListener () {
409409 @ Override
410410 public void onTrack (@ Nonnull String eventKey , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Map <String , ?> eventTags , @ Nonnull LogEvent event ) {
@@ -413,7 +413,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M
413413 });
414414 optimizelyClient .track ("test_event" , GENERIC_USER_ID );
415415 assertTrue (notificationId <= 0 );
416- assertFalse (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
416+ assertFalse (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
417417 assertEquals (false , numberOfCalls [0 ]);
418418 verifyZeroInteractions (logger );
419419
@@ -427,7 +427,7 @@ public void testGoodTrackWithListener() {
427427 final boolean [] numberOfCalls = new boolean [1 ];
428428 numberOfCalls [0 ]= false ;
429429
430- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Track ,
430+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Track ,
431431 new TrackNotificationListener () {
432432 @ Override
433433 public void onTrack (@ Nonnull String eventKey , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Map <String , ?> eventTags , @ Nonnull LogEvent event ) {
@@ -436,7 +436,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M
436436 });
437437 optimizelyClient .track ("test_event" , GENERIC_USER_ID );
438438 assertTrue (notificationId > 0 );
439- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
439+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
440440 if (datafileVersion == 3 ) {
441441 assertEquals (true , numberOfCalls [0 ]);
442442 }
@@ -1051,77 +1051,6 @@ public void testDefaultAttributes() {
10511051 Assert .assertEquals (map .size (), 4 );
10521052 }
10531053
1054- //======== Notification listeners ========//
1055-
1056- @ Test
1057- public void testGoodAddNotificationListener () {
1058- OptimizelyClient optimizelyClient = new OptimizelyClient (optimizely ,
1059- logger );
1060- NotificationListener listener = new NotificationListener () {
1061- @ Override
1062- public void onExperimentActivated (Experiment experiment ,
1063- String s ,
1064- Map <String , String > map ,
1065- Variation variation ) {
1066- }
1067-
1068- @ Override
1069- public void notify (Object ... args ) {}
1070- };
1071- optimizelyClient .addNotificationListener (listener );
1072- optimizelyClient .removeNotificationListener (listener );
1073- verifyZeroInteractions (logger );
1074- }
1075-
1076- @ Test
1077- public void testBadAddNotificationListener () {
1078- OptimizelyClient optimizelyClient = new OptimizelyClient (null , logger );
1079- NotificationListener listener = new NotificationListener () {
1080- @ Override
1081- public void onExperimentActivated (Experiment experiment ,
1082- String s ,
1083- Map <String , String > map ,
1084- Variation variation ) {
1085- }
1086-
1087- @ Override
1088- public void notify (Object ... args ) {}
1089- };
1090- optimizelyClient .addNotificationListener (listener );
1091- verify (logger ).warn ("Optimizely is not initialized, could not add notification listener" );
1092- }
1093-
1094- @ Test
1095- public void testBadRemoveNotificationListener () {
1096- OptimizelyClient optimizelyClient = new OptimizelyClient (null , logger );
1097- NotificationListener listener = new NotificationListener () {
1098- @ Override
1099- public void onExperimentActivated (Experiment experiment ,
1100- String s ,
1101- Map <String , String > map ,
1102- Variation variation ) {
1103- }
1104- @ Override
1105- public void notify (Object ... args ) {}
1106- };
1107- optimizelyClient .removeNotificationListener (listener );
1108- verify (logger ).warn ("Optimizely is not initialized, could not remove notification listener" );
1109- }
1110-
1111- @ Test
1112- public void testGoodClearNotificationListeners () {
1113- OptimizelyClient optimizelyClient = new OptimizelyClient (optimizely , logger );
1114- optimizelyClient .clearNotificationListeners ();
1115- verifyZeroInteractions (logger );
1116- }
1117-
1118- @ Test
1119- public void testBadClearNotificationListeners () {
1120- OptimizelyClient optimizelyClient = new OptimizelyClient (null , logger );
1121- optimizelyClient .clearNotificationListeners ();
1122- verify (logger ).warn ("Optimizely is not initialized, could not clear notification listeners" );
1123- }
1124-
11251054 //Feature variation Testing
11261055
11271056 //Test when optimizelyClient initialized with valid optimizely and without attributes
@@ -1252,6 +1181,7 @@ public void testGetEnabledFeaturesWithValidUserID(){
12521181 optimizely ,
12531182 logger
12541183 );
1184+
12551185 List <String > enabledFeatures = optimizelyClient .getEnabledFeatures (GENERIC_USER_ID ,
12561186 Collections .singletonMap ("house" , "Gryffindor" ));
12571187 assertFalse (enabledFeatures .isEmpty ());
0 commit comments