DayViewModel extends BaseObservable { public void init() { RepositoryProvider.provideNasaRepository() .dayPicture() .doOnSubscribe(() -> setLoading(true)) .doOnTerminate(() -> setLoading(false)) .compose(mLifecycleHandler.load(R.id.day_picture_request)) .subscribe(dayPicture -> { mDayPicture = dayPicture; notifyPropertyChanged(BR.title); notifyPropertyChanged(BR.explanation); notifyPropertyChanged(BR.url); }, throwable -> { }); } DayViewModel(@NonNull LifecycleHandler lifecycleHandler); void init(); @Bindable @NonNull String getTitle(); @Bindable @NonNull String getExplanation(); @Bindable @NonNull String getUrl(); @Bindable boolean isLoading();  }
@Test public void testDataLoaded() throws Exception { NasaRepository repository = Mockito.mock(NasaRepository.class); Observable<DayPicture> observable = Observable.just(new DayPicture()); Mockito.when(repository.dayPicture()).thenReturn(observable); RepositoryProvider.setNasaRepository(repository); mViewModel.init(); Mockito.verify(mViewModel).notifyPropertyChanged(BR.title); Mockito.verify(mViewModel).notifyPropertyChanged(BR.explanation); Mockito.verify(mViewModel).notifyPropertyChanged(BR.url); }