### Question:
AccountsManager { String getSkuToken() { if (isManaged) { if (isExpired()) { skuToken = generateSkuToken(getUserId()); timestamp = persistRotation(skuToken); } } else { SharedPreferences sharedPreferences = getSharedPreferences(); String notManagedSkuToken = sharedPreferences.getString(KEY_PREFERENCE_SKU_TOKEN, ""); skuToken = notManagedSkuToken; } return skuToken; } AccountsManager(); @VisibleForTesting  AccountsManager(SharedPreferences sharedPreferences, boolean isManaged);   }### Answer:
@Test public void checksSkuTokenExternalManagement() { SharedPreferences mockedSharedPreferences = mock(SharedPreferences.class); when(mockedSharedPreferences.getString(KEY_PREFERENCE_SKU_TOKEN, "")).thenReturn("external-sku-token"); boolean isNotManaged = false; AccountsManager theAccountsManager = new AccountsManager(mockedSharedPreferences, isNotManaged); String skuToken = theAccountsManager.getSkuToken(); assertEquals("external-sku-token", skuToken); }
@Test public void checksSkuTokenInternalManagement() { SharedPreferences mockedSharedPreferences = mock(SharedPreferences.class, RETURNS_DEEP_STUBS); when(mockedSharedPreferences.getString("com.mapbox.mapboxsdk.accounts.userid", "")) .thenReturn("any-user-id"); boolean isManaged = true; AccountsManager theAccountsManager = new AccountsManager(mockedSharedPreferences, isManaged); String skuToken = theAccountsManager.getSkuToken(); assertFalse(skuToken.isEmpty()); assertTrue(skuToken.startsWith("100")); assertTrue(skuToken.endsWith("any-user-id")); }