FirebaseUtils { static boolean isFirebaseAvailable() { try { getFirebaseInstanceId(); return true; } catch (FirebaseUnavailableException e) { return false; } } @VisibleForTesting  FirebaseUtils();   }
@Test public void firebaseUnavailable() { IllegalStateException exception = new IllegalStateException("Not init."); when(FirebaseInstanceId.getInstance()).thenThrow(exception); assertFalse(FirebaseUtils.isFirebaseAvailable()); }
@Test public void firebaseIsAvailable() { FirebaseInstanceId instanceId = mock(FirebaseInstanceId.class); when(FirebaseInstanceId.getInstance()).thenReturn(instanceId); when(instanceId.getToken()).thenReturn("token"); assertTrue(FirebaseUtils.isFirebaseAvailable()); }
@Test public void firebaseNullInstance() { assertFalse(FirebaseUtils.isFirebaseAvailable()); }