@Test public void testGetStoriesSuccess() { AlgoliaClient.AlgoliaHits hits = new GsonBuilder().create().fromJson( "{\"hits\":[{\"objectID\":\"1\"}]}", AlgoliaClient.AlgoliaHits.class); when(TestRestServiceFactory.algoliaRestService.searchByDateRx(eq("filter"))) .thenReturn(Observable.just(hits)); client.getStories("filter", ItemManager.MODE_DEFAULT, storiesListener); verify(TestRestServiceFactory.algoliaRestService).searchByDateRx(eq("filter")); verify(storiesListener).onResponse(getStoriesResponse.capture()); assertThat(getStoriesResponse.getValue()).hasSize(1); }
@Override public void getStories(String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } searchRx(filter) .map(this::toItems) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); }
AlgoliaClient implements ItemManager { @Override public void getStories(String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } searchRx(filter) .map(this::toItems) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } }
AlgoliaClient implements ItemManager { @Override public void getStories(String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } searchRx(filter) .map(this::toItems) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  AlgoliaClient(RestServiceFactory factory); }
AlgoliaClient implements ItemManager { @Override public void getStories(String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } searchRx(filter) .map(this::toItems) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  AlgoliaClient(RestServiceFactory factory); @Override void getStories(String filter, @CacheMode int cacheMode,
                           final ResponseListener<Item[]> listener); @Override void getItem(String itemId, @CacheMode int cacheMode, ResponseListener<Item> listener); @Override Item[] getStories(String filter, @CacheMode int cacheMode); @Override Item getItem(String itemId, @CacheMode int cacheMode); }
AlgoliaClient implements ItemManager { @Override public void getStories(String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } searchRx(filter) .map(this::toItems) .observeOn(mMainThreadScheduler) .subscribe(listener::onResponse, t -> listener.onError(t != null ? t.getMessage() : "")); } @Inject  AlgoliaClient(RestServiceFactory factory); @Override void getStories(String filter, @CacheMode int cacheMode,
                           final ResponseListener<Item[]> listener); @Override void getItem(String itemId, @CacheMode int cacheMode, ResponseListener<Item> listener); @Override Item[] getStories(String filter, @CacheMode int cacheMode); @Override Item getItem(String itemId, @CacheMode int cacheMode); static boolean sSortByTime; static final String HOST; }