DataManager { public Single<AccountsResponse> getAccounts() { String token = buildAuthorization(); return mMondroidService.getAccounts(token); } @Inject  DataManager(MondroidService mondroidService, PreferencesHelper preferencesHelper); Single<AccessToken> getAccessToken(String code); Single<Boolean> isUserSignedIn(); Completable signOut(); Single<AccountsResponse> getAccounts(); Single<AccountData> getAccountDetails(); Single<Balance> getBalance(String accountId); Single<List<Transaction>> getTransactions(String accountId);  }
@Test public void getAccountsCompletesAndEmitsAccounts() { stubPreferencesHelperGetAccessToken(TestDataFactory.makeAccessToken()); List<Account> accounts = TestDataFactory.makeAccounts(5); MondroidService.AccountsResponse accountsResponse = new MondroidService.AccountsResponse(); accountsResponse.accounts = accounts; stubMondoServiceGetAccounts(Single.just(accountsResponse)); TestSubscriber<MondroidService.AccountsResponse> testSubscriber = new TestSubscriber<>(); mDataManager.getAccounts().subscribe(testSubscriber); testSubscriber.assertCompleted(); testSubscriber.assertValue(accountsResponse); }