@@ -90,6 +90,8 @@ public class FirebaseInstallationsTest {
90
90
91
91
public static final String TEST_INSTANCE_ID_1 = "ccccccccccc" ;
92
92
93
+ public static final String TEST_INSTANCE_ID_TOKEN_1 = "iid.token" ;
94
+
93
95
public static final InstallationResponse TEST_INSTALLATION_RESPONSE =
94
96
InstallationResponse .builder ()
95
97
.setUri ("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_1 )
@@ -185,6 +187,7 @@ public void testGetId_noNetwork_noIid() throws Exception {
185
187
when (mockBackend .generateAuthToken (anyString (), anyString (), anyString (), anyString ()))
186
188
.thenThrow (new IOException ());
187
189
when (mockIidStore .readIid ()).thenReturn (null );
190
+ when (mockIidStore .readToken ()).thenReturn (null );
188
191
189
192
// Do the actual getId() call under test. Confirm that it returns a generated FID and
190
193
// and that the FID was written to storage.
@@ -210,11 +213,16 @@ public void testGetId_noNetwork_noIid() throws Exception {
210
213
@ Test
211
214
public void testGetId_noNetwork_iidPresent () throws Exception {
212
215
when (mockBackend .createFirebaseInstallation (
213
- anyString (), anyString (), anyString (), anyString (), any ()))
216
+ TEST_API_KEY ,
217
+ TEST_INSTANCE_ID_1 ,
218
+ TEST_PROJECT_ID ,
219
+ TEST_APP_ID_1 ,
220
+ TEST_INSTANCE_ID_TOKEN_1 ))
214
221
.thenThrow (new IOException ());
215
222
when (mockBackend .generateAuthToken (anyString (), anyString (), anyString (), anyString ()))
216
223
.thenThrow (new IOException ());
217
224
when (mockIidStore .readIid ()).thenReturn (TEST_INSTANCE_ID_1 );
225
+ when (mockIidStore .readToken ()).thenReturn (TEST_INSTANCE_ID_TOKEN_1 );
218
226
219
227
// Do the actual getId() call under test. Confirm that it returns a generated FID and
220
228
// and that the FID was written to storage.
@@ -340,8 +348,9 @@ public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception {
340
348
@ Test
341
349
public void testGetId_migrateIid_successful () throws Exception {
342
350
when (mockIidStore .readIid ()).thenReturn (TEST_INSTANCE_ID_1 );
351
+ when (mockIidStore .readToken ()).thenReturn (TEST_INSTANCE_ID_TOKEN_1 );
343
352
when (mockBackend .createFirebaseInstallation (
344
- anyString (), anyString (), anyString (), anyString (), any ()))
353
+ anyString (), anyString (), anyString (), anyString (), anyString ()))
345
354
.thenReturn (TEST_INSTALLATION_RESPONSE_WITH_IID );
346
355
347
356
// Do the actual getId() call under test.
@@ -367,6 +376,7 @@ public void testGetId_migrateIid_successful() throws Exception {
367
376
@ Test
368
377
public void testGetId_multipleCalls_sameFIDReturned () throws Exception {
369
378
when (mockIidStore .readIid ()).thenReturn (null );
379
+ when (mockIidStore .readToken ()).thenReturn (null );
370
380
when (mockBackend .createFirebaseInstallation (
371
381
anyString (), anyString (), anyString (), anyString (), any ()))
372
382
.thenReturn (TEST_INSTALLATION_RESPONSE );
0 commit comments