UserManager { public boolean userExists(String siteUrl, String username) { return getAccountForUser(siteUrl, username) != null; } 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 userExists_usernameAndUrlMatchAnAccount_returnsTrue() { Account account = new Account(ACCOUNT_NAME, ACCOUNT_TYPE); when(accountManager.getAccountsByType(ACCOUNT_TYPE)).thenReturn(new Account[] {account}); assertThat(userManager.userExists(SITE_URL, USERNAME)).isTrue(); }
@Test public void userExists_usernameAndUrlDoNotMatchAnAccount_returnsFalse() { Account account = new Account("another_name", ACCOUNT_TYPE); when(accountManager.getAccountsByType(ACCOUNT_TYPE)).thenReturn(new Account[] {account}); assertThat(userManager.userExists(SITE_URL, USERNAME)).isFalse(); }