@@ -1229,14 +1229,14 @@ public void testChangeAppId_duringRuntime() throws Exception {
1229
1229
1230
1230
@ Test
1231
1231
public void testUserDeletedFromServer () throws Exception {
1232
- // First cold boot normal
1232
+ // 1. Open app and register for the first time.
1233
1233
OneSignalInit ();
1234
1234
threadAndTaskWait ();
1235
1235
1236
1236
int normalCreateFieldCount = ShadowOneSignalRestClient .lastPost .length ();
1237
1237
ShadowOneSignalRestClient .lastPost = null ;
1238
1238
1239
- // Developer deletes user, cold boots apps should resend all fields
1239
+ // 2. Developer deletes user and cold restarts the app
1240
1240
restartAppAndElapseTimeToNextSession ();
1241
1241
ShadowOneSignalRestClient .failNext = true ;
1242
1242
ShadowOneSignalRestClient .setNextFailureJSONResponse (new JSONObject () {{
@@ -1247,21 +1247,24 @@ public void testUserDeletedFromServer() throws Exception {
1247
1247
OneSignalInit ();
1248
1248
threadAndTaskWait ();
1249
1249
1250
+ // 3. Assert the SDK handles the error above and make a new create call.
1251
+ assertPlayerCreatePushAtIndex (4 );
1252
+ // Checking that the number of fields matches exactly to the original create call.
1250
1253
assertEquals (normalCreateFieldCount , ShadowOneSignalRestClient .lastPost .length ());
1251
1254
1252
-
1253
- // Developer deletes users again from dashboard while app is running.
1254
- ShadowOneSignalRestClient .lastPost = null ;
1255
+ // 4. Developer deletes users again from dashboard while app is running.
1255
1256
ShadowOneSignalRestClient .failNext = true ;
1256
1257
ShadowOneSignalRestClient .setNextFailureJSONResponse (new JSONObject () {{
1257
- put ("errors" , new JSONArray () {{
1258
- put ("No user with this id found" );
1259
- }});
1258
+ put ("errors" , new JSONArray ().put ("No user with this id found" ));
1260
1259
}});
1260
+ // 5. Make some call the will attempt a player update
1261
1261
OneSignal .sendTag ("key1" , "value1" );
1262
1262
threadAndTaskWait ();
1263
1263
1264
- assertEquals (normalCreateFieldCount , ShadowOneSignalRestClient .lastPost .length () - 1 );
1264
+ // 6. Assert the SDK handles the error above and make a new create call.
1265
+ assertPlayerCreatePushAtIndex (6 );
1266
+ // Checking that the number of fields matches original create call, +1 for tags
1267
+ assertEquals (normalCreateFieldCount + 1 , ShadowOneSignalRestClient .lastPost .length ());
1265
1268
}
1266
1269
1267
1270
@ Test
0 commit comments