@@ -1229,14 +1229,14 @@ public void testChangeAppId_duringRuntime() throws Exception {
12291229
12301230 @ Test
12311231 public void testUserDeletedFromServer () throws Exception {
1232- // First cold boot normal
1232+ // 1. Open app and register for the first time.
12331233 OneSignalInit ();
12341234 threadAndTaskWait ();
12351235
12361236 int normalCreateFieldCount = ShadowOneSignalRestClient .lastPost .length ();
12371237 ShadowOneSignalRestClient .lastPost = null ;
12381238
1239- // Developer deletes user, cold boots apps should resend all fields
1239+ // 2. Developer deletes user and cold restarts the app
12401240 restartAppAndElapseTimeToNextSession ();
12411241 ShadowOneSignalRestClient .failNext = true ;
12421242 ShadowOneSignalRestClient .setNextFailureJSONResponse (new JSONObject () {{
@@ -1247,21 +1247,24 @@ public void testUserDeletedFromServer() throws Exception {
12471247 OneSignalInit ();
12481248 threadAndTaskWait ();
12491249
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.
12501253 assertEquals (normalCreateFieldCount , ShadowOneSignalRestClient .lastPost .length ());
12511254
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.
12551256 ShadowOneSignalRestClient .failNext = true ;
12561257 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" ));
12601259 }});
1260+ // 5. Make some call the will attempt a player update
12611261 OneSignal .sendTag ("key1" , "value1" );
12621262 threadAndTaskWait ();
12631263
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 ());
12651268 }
12661269
12671270 @ Test
0 commit comments