UserManager { public boolean hasAccounts() { return countOfAcounts() > 0; } UserManager(AccountManager accountManager, Resources resources, PreferencesRepository preferencesRepository, Context ctx); CacheDatabase getDatabaseForCurrent(); void refreshAccounts(); int countOfAcounts(); boolean hasAccounts(); Account getAccountForUser(String siteUrl, String username); boolean userExists(String siteUrl, String username); Account createUser(String siteUrl, String username, String password); LiveData<Account> getActiveAccount(); LiveData<List<Account>> getAccounts(); String getSiteUrl(Account account); String getUsername(Account account); String getPassword(Account account); Cookie sessionCookie(); void setSessionCookie(Cookie cookie); String sessionToken(); void setSessionToken(String token); void setChunkSize(Account account, int chunkSize); int getChunkSize(Account account); boolean isGuest(Account account); void setActiveAccount(Account activeAccount); void setActiveAccount(String activeAccount); void replaceAccount(@NonNull Account account, @NonNull String url, String username, String password); void removeAccount(Account account); String validateUrl(String url);  }
@Test public void isLoggedIn_accountsExist_returnsTrue() { when(accountManager.getAccountsByType(ACCOUNT_TYPE)).thenReturn(new Account[1]); assertThat(userManager.hasAccounts()).isTrue(); }
@Test public void isLoggedIn_noAccountsExist_returnsFalse() { when(accountManager.getAccountsByType(ACCOUNT_TYPE)).thenReturn(new Account[0]); assertThat(userManager.hasAccounts()).isFalse(); }