Created
April 28, 2016 15:44
-
-
Save aleien/277810ff13ac759af86b37da8b8b8941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeedLoader { | |
public Observable<FeedResponse> loadFeedsList() { | |
return feedWebService.getFeeds(); | |
} | |
} | |
public class FeedSubscriber { | |
feedLoader = new FeedLoader(); | |
public void loadFeedsList() { | |
feedLoader.loadFeedsList() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(feeds -> { | |
getView().setToolbarPager(adapter); | |
}, throwable -> { | |
getView().showConnectionError(); | |
}); | |
} | |
} | |
public class SubscriberTest { | |
@Mock | |
BlaFeedLoader feedLoader; | |
... | |
when(feedLoader.loadFeedsList()) | |
.thenReturn(Observable.<FeedResponse>error(new Throwable("Connection error"))); | |
feedSubscriber.loadFeedList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment