DataManager { public Single<List<Transaction>> getTransactions(String accountId) { String token = buildAuthorization(); return mMondroidService.getTransactions(token, accountId, "merchant") .map(new Func1<MondroidService.TransactionResponse, List<Transaction>>() { @Override public List<Transaction> call(MondroidService.TransactionResponse transactionResponse) { return transactionResponse.transactions; } }); } @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 getTransactionsCompletesAndEmitsTransactions() { stubPreferencesHelperGetAccessToken(TestDataFactory.makeAccessToken()); List<Transaction> transactions = TestDataFactory.makeTransactions(5); MondroidService.TransactionResponse transactionResponse = new MondroidService.TransactionResponse(); transactionResponse.transactions = transactions; stubMondoServiceGetTransactions(Single.just(transactionResponse)); TestSubscriber<List<Transaction>> testSubscriber = new TestSubscriber<>(); mDataManager.getTransactions("account_id").subscribe(testSubscriber); testSubscriber.assertCompleted(); testSubscriber.assertValue(transactions); }