@@ -188,7 +188,7 @@ public void testGoodActivationWithListener() {
188
188
final Variation [] callbackVariation = new Variation [1 ];
189
189
190
190
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 () {
192
192
@ Override
193
193
public void onActivate (@ Nonnull Experiment experiment , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Variation variation , @ Nonnull LogEvent event ) {
194
194
callbackCalled [0 ] = true ;
@@ -202,13 +202,13 @@ public void onActivate(@Nonnull Experiment experiment, @Nonnull String userId, @
202
202
assertEquals (v , callbackVariation [0 ]);
203
203
assertEquals (true , callbackCalled [0 ]);
204
204
assertEquals (1 , notificationId );
205
- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
205
+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
206
206
}
207
207
else {
208
208
assertNull (v );
209
209
assertEquals (false , callbackCalled [0 ]);
210
210
assertEquals (1 , notificationId );
211
- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
211
+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
212
212
}
213
213
214
214
}
@@ -220,7 +220,7 @@ public void testBadActivationWithListener() {
220
220
final boolean [] callbackCalled = new boolean [1 ];
221
221
222
222
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 () {
224
224
@ Override
225
225
public void onTrack (@ Nonnull String eventKey , @ Nonnull String userId , @ Nonnull Map <String , String > attributes , @ Nonnull Map <String , ?> eventTags , @ Nonnull LogEvent event ) {
226
226
callbackCalled [0 ] = true ;
@@ -231,7 +231,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M
231
231
232
232
assertEquals (false , callbackCalled [0 ]);
233
233
assertTrue (notificationId <= 0 );
234
- assertFalse (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
234
+ assertFalse (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
235
235
236
236
}
237
237
@@ -404,7 +404,7 @@ public void testBadTrackWithListener() {
404
404
final boolean [] numberOfCalls = new boolean [1 ];
405
405
numberOfCalls [0 ]= false ;
406
406
407
- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Activate ,
407
+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Activate ,
408
408
new TrackNotificationListener () {
409
409
@ Override
410
410
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
413
413
});
414
414
optimizelyClient .track ("test_event" , GENERIC_USER_ID );
415
415
assertTrue (notificationId <= 0 );
416
- assertFalse (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
416
+ assertFalse (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
417
417
assertEquals (false , numberOfCalls [0 ]);
418
418
verifyZeroInteractions (logger );
419
419
@@ -427,7 +427,7 @@ public void testGoodTrackWithListener() {
427
427
final boolean [] numberOfCalls = new boolean [1 ];
428
428
numberOfCalls [0 ]= false ;
429
429
430
- int notificationId = optimizelyClient .getNotificationCenter ().addNotification (NotificationCenter .NotificationType .Track ,
430
+ int notificationId = optimizelyClient .getNotificationCenter ().addNotificationListener (NotificationCenter .NotificationType .Track ,
431
431
new TrackNotificationListener () {
432
432
@ Override
433
433
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
436
436
});
437
437
optimizelyClient .track ("test_event" , GENERIC_USER_ID );
438
438
assertTrue (notificationId > 0 );
439
- assertTrue (optimizelyClient .getNotificationCenter ().removeNotification (notificationId ));
439
+ assertTrue (optimizelyClient .getNotificationCenter ().removeNotificationListener (notificationId ));
440
440
if (datafileVersion == 3 ) {
441
441
assertEquals (true , numberOfCalls [0 ]);
442
442
}
@@ -1051,77 +1051,6 @@ public void testDefaultAttributes() {
1051
1051
Assert .assertEquals (map .size (), 4 );
1052
1052
}
1053
1053
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
-
1125
1054
//Feature variation Testing
1126
1055
1127
1056
//Test when optimizelyClient initialized with valid optimizely and without attributes
@@ -1252,6 +1181,7 @@ public void testGetEnabledFeaturesWithValidUserID(){
1252
1181
optimizely ,
1253
1182
logger
1254
1183
);
1184
+
1255
1185
List <String > enabledFeatures = optimizelyClient .getEnabledFeatures (GENERIC_USER_ID ,
1256
1186
Collections .singletonMap ("house" , "Gryffindor" ));
1257
1187
assertFalse (enabledFeatures .isEmpty ());
0 commit comments