20
20
import static org .junit .Assert .assertThat ;
21
21
import static org .junit .Assert .assertTrue ;
22
22
import static org .junit .Assert .fail ;
23
+ import static org .mockito .ArgumentMatchers .any ;
23
24
import static org .mockito .ArgumentMatchers .anyString ;
24
25
import static org .mockito .ArgumentMatchers .matches ;
25
26
import static org .mockito .Mockito .doAnswer ;
@@ -178,7 +179,8 @@ public void cleanUp() {
178
179
*/
179
180
@ Test
180
181
public void testGetId_noNetwork_noIid () throws Exception {
181
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
182
+ when (mockBackend .createFirebaseInstallation (
183
+ anyString (), anyString (), anyString (), anyString (), any ()))
182
184
.thenThrow (new IOException ());
183
185
when (mockBackend .generateAuthToken (anyString (), anyString (), anyString (), anyString ()))
184
186
.thenThrow (new IOException ());
@@ -207,7 +209,8 @@ public void testGetId_noNetwork_noIid() throws Exception {
207
209
208
210
@ Test
209
211
public void testGetId_noNetwork_iidPresent () throws Exception {
210
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
212
+ when (mockBackend .createFirebaseInstallation (
213
+ anyString (), anyString (), anyString (), anyString (), any ()))
211
214
.thenThrow (new IOException ());
212
215
when (mockBackend .generateAuthToken (anyString (), anyString (), anyString (), anyString ()))
213
216
.thenThrow (new IOException ());
@@ -236,7 +239,8 @@ public void testGetId_noNetwork_iidPresent() throws Exception {
236
239
237
240
@ Test
238
241
public void testGetId_noNetwork_fidAlreadyGenerated () throws Exception {
239
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
242
+ when (mockBackend .createFirebaseInstallation (
243
+ anyString (), anyString (), anyString (), anyString (), any ()))
240
244
.thenThrow (new IOException ());
241
245
when (mockBackend .generateAuthToken (anyString (), anyString (), anyString (), anyString ()))
242
246
.thenThrow (new IOException ());
@@ -303,7 +307,7 @@ public void testGetId_ValidIdAndToken_NoBackendCalls() throws Exception {
303
307
@ Test
304
308
public void testGetId_UnRegisteredId_IssueCreateIdCall () throws Exception {
305
309
when (mockBackend .createFirebaseInstallation (
306
- anyString (), matches (TEST_FID_1 ), anyString (), anyString ()))
310
+ anyString (), matches (TEST_FID_1 ), anyString (), anyString (), any () ))
307
311
.thenReturn (TEST_INSTALLATION_RESPONSE );
308
312
persistedInstallation .insertOrUpdatePersistedInstallationEntry (
309
313
PersistedInstallationEntry .INSTANCE .withUnregisteredFid (TEST_FID_1 ));
@@ -322,7 +326,8 @@ public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception {
322
326
// check that the mockClient didn't get invoked at all, since the fid is already registered
323
327
// and the authtoken is present and not expired
324
328
verify (mockBackend )
325
- .createFirebaseInstallation (anyString (), matches (TEST_FID_1 ), anyString (), anyString ());
329
+ .createFirebaseInstallation (
330
+ anyString (), matches (TEST_FID_1 ), anyString (), anyString (), any ());
326
331
verify (mockBackend , never ())
327
332
.generateAuthToken (anyString (), anyString (), anyString (), anyString ());
328
333
@@ -335,7 +340,8 @@ public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception {
335
340
@ Test
336
341
public void testGetId_migrateIid_successful () throws Exception {
337
342
when (mockIidStore .readIid ()).thenReturn (TEST_INSTANCE_ID_1 );
338
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
343
+ when (mockBackend .createFirebaseInstallation (
344
+ anyString (), anyString (), anyString (), anyString (), any ()))
339
345
.thenReturn (TEST_INSTALLATION_RESPONSE_WITH_IID );
340
346
341
347
// Do the actual getId() call under test.
@@ -361,7 +367,8 @@ public void testGetId_migrateIid_successful() throws Exception {
361
367
@ Test
362
368
public void testGetId_multipleCalls_sameFIDReturned () throws Exception {
363
369
when (mockIidStore .readIid ()).thenReturn (null );
364
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
370
+ when (mockBackend .createFirebaseInstallation (
371
+ anyString (), anyString (), anyString (), anyString (), any ()))
365
372
.thenReturn (TEST_INSTALLATION_RESPONSE );
366
373
367
374
// Call getId multiple times
@@ -384,7 +391,7 @@ public void testGetId_multipleCalls_sameFIDReturned() throws Exception {
384
391
.that (task2 .getResult ())
385
392
.isEqualTo (TEST_FID_1 );
386
393
verify (mockBackend , times (1 ))
387
- .createFirebaseInstallation (TEST_API_KEY , TEST_FID_1 , TEST_PROJECT_ID , TEST_APP_ID_1 );
394
+ .createFirebaseInstallation (TEST_API_KEY , TEST_FID_1 , TEST_PROJECT_ID , TEST_APP_ID_1 , null );
388
395
PersistedInstallationEntry entry = persistedInstallation .readPersistedInstallationEntryValue ();
389
396
assertThat (entry .getFirebaseInstallationId (), equalTo (TEST_FID_1 ));
390
397
assertTrue ("the entry isn't doesn't have a registered fid: " + entry , entry .isRegistered ());
@@ -399,7 +406,8 @@ public void testGetId_unregistered_replacesFidWithResponse() throws Exception {
399
406
// Update local storage with installation entry that has invalid fid.
400
407
persistedInstallation .insertOrUpdatePersistedInstallationEntry (
401
408
PersistedInstallationEntry .INSTANCE .withUnregisteredFid ("tobereplaced" ));
402
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
409
+ when (mockBackend .createFirebaseInstallation (
410
+ anyString (), anyString (), anyString (), anyString (), any ()))
403
411
.thenReturn (TEST_INSTALLATION_RESPONSE );
404
412
405
413
// The first call will return the existing FID, "tobereplaced"
@@ -435,7 +443,8 @@ public void testGetId_ServerError_UnregisteredFID() throws Exception {
435
443
PersistedInstallationEntry .INSTANCE .withUnregisteredFid (TEST_FID_1 ));
436
444
437
445
// have the server return a server error for the registration
438
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
446
+ when (mockBackend .createFirebaseInstallation (
447
+ anyString (), anyString (), anyString (), anyString (), any ()))
439
448
.thenReturn (
440
449
InstallationResponse .builder ().setResponseCode (ResponseCode .BAD_CONFIG ).build ());
441
450
@@ -469,7 +478,8 @@ public void testGetId_fidRegistrationUncheckedException_statusUpdated() throws E
469
478
PersistedInstallationEntry .INSTANCE .withUnregisteredFid (TEST_FID_1 ));
470
479
471
480
// Mocking unchecked exception on FIS createFirebaseInstallation
472
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
481
+ when (mockBackend .createFirebaseInstallation (
482
+ anyString (), anyString (), anyString (), anyString (), any ()))
473
483
.thenThrow (new IOException ());
474
484
475
485
TestOnCompleteListener <String > onCompleteListener = new TestOnCompleteListener <>();
@@ -569,14 +579,15 @@ public void testGetId_expiredAuthToken_refreshesAuthToken() throws Exception {
569
579
.isEqualTo (TEST_AUTH_TOKEN_2 );
570
580
571
581
verify (mockBackend , never ())
572
- .createFirebaseInstallation (TEST_API_KEY , TEST_FID_1 , TEST_PROJECT_ID , TEST_APP_ID_1 );
582
+ .createFirebaseInstallation (TEST_API_KEY , TEST_FID_1 , TEST_PROJECT_ID , TEST_APP_ID_1 , null );
573
583
verify (mockBackend , times (1 ))
574
584
.generateAuthToken (TEST_API_KEY , TEST_FID_1 , TEST_PROJECT_ID , TEST_REFRESH_TOKEN );
575
585
}
576
586
577
587
@ Test
578
588
public void testGetAuthToken_fidDoesNotExist_successful () throws Exception {
579
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
589
+ when (mockBackend .createFirebaseInstallation (
590
+ anyString (), anyString (), anyString (), anyString (), any ()))
580
591
.thenReturn (TEST_INSTALLATION_RESPONSE );
581
592
582
593
TestOnCompleteListener <InstallationTokenResult > onCompleteListener =
@@ -650,7 +661,8 @@ public void testGetToken_unregisteredFid_fetchedNewTokenFromFIS() throws Excepti
650
661
// calls getId to ensure FID registration and returns a valid auth token.
651
662
persistedInstallation .insertOrUpdatePersistedInstallationEntry (
652
663
PersistedInstallationEntry .INSTANCE .withUnregisteredFid (TEST_FID_1 ));
653
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
664
+ when (mockBackend .createFirebaseInstallation (
665
+ anyString (), anyString (), anyString (), anyString (), any ()))
654
666
.thenReturn (TEST_INSTALLATION_RESPONSE );
655
667
656
668
TestOnCompleteListener <InstallationTokenResult > onCompleteListener =
@@ -859,7 +871,8 @@ public void testDelete_registeredFID_successful() throws Exception {
859
871
utils .currentTimeInSecs (),
860
872
TEST_AUTH_TOKEN ,
861
873
TEST_TOKEN_EXPIRATION_TIMESTAMP ));
862
- when (mockBackend .createFirebaseInstallation (anyString (), anyString (), anyString (), anyString ()))
874
+ when (mockBackend .createFirebaseInstallation (
875
+ anyString (), anyString (), anyString (), anyString (), any ()))
863
876
.thenReturn (TEST_INSTALLATION_RESPONSE );
864
877
865
878
TestOnCompleteListener <Void > onCompleteListener = new TestOnCompleteListener <>();
0 commit comments