@Test public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); when(mRepositoryRestApi.searchResources(anyMapOf(String.class, Object.class))).thenReturn(mResult); List<Resource> resources = new ArrayList<Resource>(); when(mDataMapper.toResources(anyCollectionOf(ResourceLookup.class), Matchers.any(SimpleDateFormat.class))).thenReturn(resources); SearchResult result = objectUnderTest.performSearch(mCriteria); assertThat(result, is(not(nullValue()))); assertThat(result.getNextOffset(), is(100)); assertThat(result.getResources(), is(resources)); verify(mRepositoryRestApi).searchResources(anyMapOf(String.class, Object.class)); }
@NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call<SearchResult> call = new Call<SearchResult>() { @Override public SearchResult perform() throws IOException, HttpException { Map<String, Object> criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); List<Resource> resources = mDataMapper.toResources(response.getResources(), dateTimeFormat); return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); }
SearchUseCase { @NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call<SearchResult> call = new Call<SearchResult>() { @Override public SearchResult perform() throws IOException, HttpException { Map<String, Object> criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); List<Resource> resources = mDataMapper.toResources(response.getResources(), dateTimeFormat); return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); } }
SearchUseCase { @NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call<SearchResult> call = new Call<SearchResult>() { @Override public SearchResult perform() throws IOException, HttpException { Map<String, Object> criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); List<Resource> resources = mDataMapper.toResources(response.getResources(), dateTimeFormat); return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); } SearchUseCase(ResourcesMapper dataMapper,
                  RepositoryRestApi restApi,
                  InfoCacheManager infoCacheManager,
                  CallExecutor callExecutor); }
SearchUseCase { @NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call<SearchResult> call = new Call<SearchResult>() { @Override public SearchResult perform() throws IOException, HttpException { Map<String, Object> criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); List<Resource> resources = mDataMapper.toResources(response.getResources(), dateTimeFormat); return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); } SearchUseCase(ResourcesMapper dataMapper,
                  RepositoryRestApi restApi,
                  InfoCacheManager infoCacheManager,
                  CallExecutor callExecutor); @NotNull SearchResult performSearch(@NotNull final InternalCriteria internalCriteria); }
SearchUseCase { @NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call<SearchResult> call = new Call<SearchResult>() { @Override public SearchResult perform() throws IOException, HttpException { Map<String, Object> criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); List<Resource> resources = mDataMapper.toResources(response.getResources(), dateTimeFormat); return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); } SearchUseCase(ResourcesMapper dataMapper,
                  RepositoryRestApi restApi,
                  InfoCacheManager infoCacheManager,
                  CallExecutor callExecutor); @NotNull SearchResult performSearch(@NotNull final InternalCriteria internalCriteria);  }