@Test public void getActiveAccount_withNoActiveAccount_returnsFirstAccount() { Account firstAccount = new Account("first_account", ACCOUNT_TYPE); Account secondAccount = new Account("second_account", ACCOUNT_TYPE); when(accountManager.getAccountsByType(ACCOUNT_TYPE)).thenReturn(new Account[] {firstAccount, secondAccount}); when(preferencesRepository.getActiveAccountName()).thenReturn(null); userManager = new UserManager(accountManager, resources, preferencesRepository, RuntimeEnvironment.systemContext); assertThat(userManager.getActiveAccount().getValue()).isEqualTo(firstAccount); }
public LiveData<Account> getActiveAccount() { return mCurrentAccount; }
UserManager { public LiveData<Account> getActiveAccount() { return mCurrentAccount; } }
UserManager { public LiveData<Account> getActiveAccount() { return mCurrentAccount; } UserManager(AccountManager accountManager, Resources resources, PreferencesRepository preferencesRepository, Context ctx); }
UserManager { public LiveData<Account> getActiveAccount() { return mCurrentAccount; } 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); }
UserManager { public LiveData<Account> getActiveAccount() { return mCurrentAccount; } 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);  }