### Question:
AccountController { public @Nullable Account getCurrentAccount() { Account[] accounts; try { accounts = mAccountManager.getAccountsByType(mAccountType); } catch (SecurityException e) { TbaLogger.w("Can't get current local account, no permission", e); return null; } String selectedAccount = getSelectedAccount(); for (Account account : accounts) { if (account.name.equals(selectedAccount)) return account; } return null; } @Inject  AccountController(
            SharedPreferences preferences,
            AccountManager accountManager,
            AppConfig appConfig,
            String accountType); void setMyTbaEnabled(boolean enabled); boolean isMyTbaEnabled(); void setSelectedAccount(String account); String getSelectedAccount(); boolean isAccountSelected(); @Nullable Account getCurrentAccount(); void onAccountConnect(Context context, User user); String getWebClientId();  }### Answer:
@Test public void testGetAccountNoneAvailable() { when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)) .thenReturn(new Account[]{}); when(mSharedPreferences.getString(PREF_SELECTED_ACCOUNT, "")).thenReturn(TEST_ACCOUNT_NAME); Account selectedAccount = mAccountController.getCurrentAccount(); assertNull(selectedAccount); }
@Test public void testGetAccountNoneSelected() { when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)) .thenReturn(new Account[]{mAccount}); when(mSharedPreferences.getString(PREF_SELECTED_ACCOUNT, "")).thenReturn(null); Account selectedAccount = mAccountController.getCurrentAccount(); assertNull(selectedAccount); }
@Test public void testGetAccount() { when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)) .thenReturn(new Account[]{mAccount}); when(mSharedPreferences.getString(PREF_SELECTED_ACCOUNT, "")).thenReturn(TEST_ACCOUNT_NAME); Account selectedAccount = mAccountController.getCurrentAccount(); assertEquals(selectedAccount, mAccount); }