@Test public void requestArticleObservable_returnsObjectWithArticle() throws Exception { final String articleId = "bnl-vkn-20161117-7352758"; final HttpUrl baseUrl = prepareAndStartServerToReturnJsonFromFile(mServer, "article(ws.blendle.com_item_" + articleId + ").json"); final ArticlesServer articlesServer = new ArticlesServer(baseUrl, RxJava2CallAdapterFactory. createWithScheduler(Schedulers.trampoline())); final Single<ArticleResource> articleObservable = articlesServer .requestArticle(articleId); final TestObserver<ArticleResource> testObserver = new TestObserver<>(); articleObservable.subscribe(testObserver); testObserver.await(2, TimeUnit.SECONDS); final List<Object> events = testObserver.getEvents().get(0); testObserver.assertNoErrors(); assertTrue("There should only one event with the request results", events.size() == 1); final ArticleResource article = (ArticleResource) events.get(0); assertEquals(articleId, article.id()); }
@Override public Single<ArticleResource> requestArticle(@NonNull final String id) { final Retrofit retrofit = new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(HALConverterFactory.create(ArticleResource.class)) .addCallAdapterFactory(mRxAdapter) .build(); final BlendleAPI blendleAPI = retrofit.create(BlendleAPI.class); return blendleAPI.articlesObservable(id); }
ArticlesServer implements ArticlesDataSource { @Override public Single<ArticleResource> requestArticle(@NonNull final String id) { final Retrofit retrofit = new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(HALConverterFactory.create(ArticleResource.class)) .addCallAdapterFactory(mRxAdapter) .build(); final BlendleAPI blendleAPI = retrofit.create(BlendleAPI.class); return blendleAPI.articlesObservable(id); } }
ArticlesServer implements ArticlesDataSource { @Override public Single<ArticleResource> requestArticle(@NonNull final String id) { final Retrofit retrofit = new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(HALConverterFactory.create(ArticleResource.class)) .addCallAdapterFactory(mRxAdapter) .build(); final BlendleAPI blendleAPI = retrofit.create(BlendleAPI.class); return blendleAPI.articlesObservable(id); } ArticlesServer();  ArticlesServer(final HttpUrl baseUrl, final CallAdapter.Factory rxAdapter); }
ArticlesServer implements ArticlesDataSource { @Override public Single<ArticleResource> requestArticle(@NonNull final String id) { final Retrofit retrofit = new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(HALConverterFactory.create(ArticleResource.class)) .addCallAdapterFactory(mRxAdapter) .build(); final BlendleAPI blendleAPI = retrofit.create(BlendleAPI.class); return blendleAPI.articlesObservable(id); } ArticlesServer();  ArticlesServer(final HttpUrl baseUrl, final CallAdapter.Factory rxAdapter); @Override PopularArticlesResource requestPopularArticles(); @Override Single<PopularArticlesResource> requestPopularArticles(@Nullable final Integer amount,
                                                                 @Nullable final Integer page); @Override Single<ArticleResource> requestArticle(@NonNull final String id); }
ArticlesServer implements ArticlesDataSource { @Override public Single<ArticleResource> requestArticle(@NonNull final String id) { final Retrofit retrofit = new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(HALConverterFactory.create(ArticleResource.class)) .addCallAdapterFactory(mRxAdapter) .build(); final BlendleAPI blendleAPI = retrofit.create(BlendleAPI.class); return blendleAPI.articlesObservable(id); } ArticlesServer();  ArticlesServer(final HttpUrl baseUrl, final CallAdapter.Factory rxAdapter); @Override PopularArticlesResource requestPopularArticles(); @Override Single<PopularArticlesResource> requestPopularArticles(@Nullable final Integer amount,
                                                                 @Nullable final Integer page); @Override Single<ArticleResource> requestArticle(@NonNull final String id);  }