CollectionViewPresenter { void onRefresh() { disposeDisposable(); disposable = map(dataProvider.fetchNewest()) .map(includeLoading()) .subscribe( new Consumer<List<?>>() { @Override public void accept(List<?> items) throws Exception { collectionView.hideRefreshing(); collectionView.setItems(items); } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { throwable.printStackTrace(); collectionView.hideRefreshing(); } }); } CollectionViewPresenter(@NonNull DataProvider<?> dataProvider);   }
@Test public void testRefreshSuccess() throws Exception { tested.onRefresh(); verify(mockedView).hideRefreshing(); verify(mockedView).setItems(eq(Arrays.asList( 1, 2, 3, 4, CollectionViewPresenter.LOADING_ITEM))); }
@Test public void testRefreshError() throws Exception { final Throwable exception = new Throwable(); when(mockedDataProvider.fetchNewest()).thenReturn(Single.error(exception)); tested.onRefresh(); verify(mockedView).hideRefreshing(); }