SplashPresenter extends BasePresenter<SplashView> { void update() { addSubscription(updateManager.update() .subscribeOn(getView().backgroundThread()) .observeOn(getView().mainThread()) .subscribe( message -> { SplashView view = getView(); if (view != null) { view.showUpdateMessage(message); } }, this::handleError, this::initLibrary ) ); } @Inject  SplashPresenter(ILibraryController libraryController, UpdateManager updateManager); @Override void onViewCreated();  }
@Test public void update() throws Exception { when(updateManager.update()).thenReturn(Observable.fromArray("message_1", "message_2", "message_3")); presenter.update(); verify(view, times(3)).showUpdateMessage(anyString()); verify(libraryController).init(); verify(view).gotoReaderActivity(); }
@Test public void updateWithError() throws Exception { when(updateManager.update()).thenReturn(Observable.error(new IOException("abort"))); presenter.update(); verify(view).showToast(anyInt()); verify(view).gotoReaderActivity(); }