LogInAction { public Observable<SevibusUser> logIn(AuthCredential credential) { return loginService.logUserIn(credential) .flatMap(userDataSource::setCurrentUser) .map(this::sendUserToFirebase) .map(this::associateWithCrashReporting); } LogInAction(UserDataSource userDataSource, LoginService loginService, FirebaseDatabase firebaseDatabase, CrashReportingTool crashReportingTool); Observable<SevibusUser> logIn(AuthCredential credential);  }
@Test public void associate_user_with_crash_reporting_tool() throws Exception { givenLoginServiceAuthRespondsOK(); action.logIn(credential) .toBlocking().subscribe(); verify(crashReportingTool).associateUser(any(SevibusUser.class)); }
@Test public void set_current_user_when_service_return_data() throws Exception { givenLoginServiceAuthRespondsOK(); action.logIn(credential) .toBlocking().subscribe(); verify(userDataSource).setCurrentUser(any(SevibusUser.class)); }
@Test public void set_current_user_on_firebase_when_firebase_return_data() throws Exception { givenLoginServiceAuthRespondsOK(); action.logIn(credential) .toBlocking().subscribe(); verify(firebaseReference).setValue(any(SevibusUser.class)); }