DataManager { public Single<Boolean> isUserSignedIn() { return Single.just(mPreferencesHelper.getAccessToken() != null); } @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 isUserSignedInReturnsTrue() { AccessToken accessToken = TestDataFactory.makeAccessToken(); stubPreferencesHelperGetAccessToken(accessToken); TestSubscriber<Boolean> testSubscriber = new TestSubscriber<>(); mDataManager.isUserSignedIn().subscribe(testSubscriber); testSubscriber.assertCompleted(); testSubscriber.assertValue(true); }
@Test public void isUserSignedInReturnsFalse() { stubPreferencesHelperGetAccessToken(null); TestSubscriber<Boolean> testSubscriber = new TestSubscriber<>(); mDataManager.isUserSignedIn().subscribe(testSubscriber); testSubscriber.assertCompleted(); testSubscriber.assertValue(false); }