@Test public void secondSearchLookupShouldUseNextOffset() throws Exception { InternalCriteria searchCriteria = new InternalCriteria.Builder().offset(0).create(); RepositorySearchTask strategy = new RepositorySearchTaskV5_6Plus(searchCriteria, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); strategy.nextLookup(); when(mResponse.getNextOffset()).thenReturn(233); strategy.nextLookup(); InternalCriteria internalCriteria = new InternalCriteria.Builder() .offset(133) .limit(100) .forceFullPage(true) .create(); verify(mResponse, times(2)).getNextOffset(); verify(mSearchUseCase).performSearch(internalCriteria); }
@NotNull @Override public List<Resource> nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } return Collections.unmodifiableList(performLookup()); }
RepositorySearchTaskV5_6Plus extends RepositorySearchTask { @NotNull @Override public List<Resource> nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } return Collections.unmodifiableList(performLookup()); } }
RepositorySearchTaskV5_6Plus extends RepositorySearchTask { @NotNull @Override public List<Resource> nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } return Collections.unmodifiableList(performLookup()); } RepositorySearchTaskV5_6Plus(InternalCriteria criteria, SearchUseCase searchUseCase); }
RepositorySearchTaskV5_6Plus extends RepositorySearchTask { @NotNull @Override public List<Resource> nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } return Collections.unmodifiableList(performLookup()); } RepositorySearchTaskV5_6Plus(InternalCriteria criteria, SearchUseCase searchUseCase); @NotNull @Override List<Resource> nextLookup(); @Override boolean hasNext(); }
RepositorySearchTaskV5_6Plus extends RepositorySearchTask { @NotNull @Override public List<Resource> nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } return Collections.unmodifiableList(performLookup()); } RepositorySearchTaskV5_6Plus(InternalCriteria criteria, SearchUseCase searchUseCase); @NotNull @Override List<Resource> nextLookup(); @Override boolean hasNext(); static final List<Resource> EMPTY_RESPONSE; }