@Test public void signUpSuccess() { when(identityManager.logInOrSignUp(signUpPayload)).thenReturn(Observable.just(loginResponse)); final TestObserver<UiIndicator<String>> testObserver = interactor.loginOrSignUp(signUpPayload).test(); testObserver.assertValues(UiIndicator.loading(), UiIndicator.success(context.getString(R.string.sign_up_success_toast))); testObserver.assertComplete(); testObserver.assertNoErrors(); }
@NonNull public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) { Logger.info(this, "Initiating user login (or sign up)"); if (this.uiIndicatorReplaySubject == null) { this.userCredentialsPayload = userCredentialsPayload; this.uiIndicatorReplaySubject = ReplaySubject.create(); identityManager.logInOrSignUp(userCredentialsPayload) .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload))) .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable))) .startWith(UiIndicator.loading()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(uiIndicatorReplaySubject); } return uiIndicatorReplaySubject; }
LoginInteractor { @NonNull public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) { Logger.info(this, "Initiating user login (or sign up)"); if (this.uiIndicatorReplaySubject == null) { this.userCredentialsPayload = userCredentialsPayload; this.uiIndicatorReplaySubject = ReplaySubject.create(); identityManager.logInOrSignUp(userCredentialsPayload) .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload))) .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable))) .startWith(UiIndicator.loading()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(uiIndicatorReplaySubject); } return uiIndicatorReplaySubject; } }
LoginInteractor { @NonNull public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) { Logger.info(this, "Initiating user login (or sign up)"); if (this.uiIndicatorReplaySubject == null) { this.userCredentialsPayload = userCredentialsPayload; this.uiIndicatorReplaySubject = ReplaySubject.create(); identityManager.logInOrSignUp(userCredentialsPayload) .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload))) .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable))) .startWith(UiIndicator.loading()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(uiIndicatorReplaySubject); } return uiIndicatorReplaySubject; } @Inject  LoginInteractor(@NonNull Context context, @NonNull IdentityManagerImpl identityManager); }
LoginInteractor { @NonNull public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) { Logger.info(this, "Initiating user login (or sign up)"); if (this.uiIndicatorReplaySubject == null) { this.userCredentialsPayload = userCredentialsPayload; this.uiIndicatorReplaySubject = ReplaySubject.create(); identityManager.logInOrSignUp(userCredentialsPayload) .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload))) .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable))) .startWith(UiIndicator.loading()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(uiIndicatorReplaySubject); } return uiIndicatorReplaySubject; } @Inject  LoginInteractor(@NonNull Context context, @NonNull IdentityManagerImpl identityManager); @NonNull synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload); @NonNull synchronized Maybe<UserCredentialsPayload> getLastUserCredentialsPayload(); synchronized void onLoginResultsConsumed(); }
LoginInteractor { @NonNull public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) { Logger.info(this, "Initiating user login (or sign up)"); if (this.uiIndicatorReplaySubject == null) { this.userCredentialsPayload = userCredentialsPayload; this.uiIndicatorReplaySubject = ReplaySubject.create(); identityManager.logInOrSignUp(userCredentialsPayload) .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload))) .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable))) .startWith(UiIndicator.loading()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(uiIndicatorReplaySubject); } return uiIndicatorReplaySubject; } @Inject  LoginInteractor(@NonNull Context context, @NonNull IdentityManagerImpl identityManager); @NonNull synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload); @NonNull synchronized Maybe<UserCredentialsPayload> getLastUserCredentialsPayload(); synchronized void onLoginResultsConsumed();  }