@Test public void shouldRecognizeIfMoreResultsAvailable() throws Exception { SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100); String html = Resources.toString(Resources.getResource(BinsearchTest.class, "/org/nzbhydra/mapping/binsearch.html"), Charsets.UTF_8); IndexerSearchResult indexerSearchResult = new IndexerSearchResult(testee, ""); testee.completeIndexerSearchResult(html, indexerSearchResult, null, searchRequest, 0, 100); assertThat(indexerSearchResult.isTotalResultsKnown(), is(false)); assertThat(indexerSearchResult.isHasMoreResults(), is(true)); }
@Override protected void completeIndexerSearchResult(String response, IndexerSearchResult indexerSearchResult, AcceptorResult acceptorResult, SearchRequest searchRequest, int offset, Integer limit) { Document doc = Jsoup.parse(response); if (doc.select("table.xMenuT").size() > 0) { Element navigationTable = doc.select("table.xMenuT").get(1); Elements pageLinks = navigationTable.select("a"); boolean hasMore = !pageLinks.isEmpty() && pageLinks.last().text().equals(">"); boolean totalKnown = false; indexerSearchResult.setOffset(searchRequest.getOffset()); int total = searchRequest.getOffset() + 100; if (!hasMore) { total = searchRequest.getOffset() + indexerSearchResult.getSearchResultItems().size(); totalKnown = true; } indexerSearchResult.setHasMoreResults(hasMore); indexerSearchResult.setTotalResults(total); indexerSearchResult.setTotalResultsKnown(totalKnown); } else { indexerSearchResult.setHasMoreResults(false); indexerSearchResult.setTotalResults(0); indexerSearchResult.setTotalResultsKnown(true); } indexerSearchResult.setLimit(limit); indexerSearchResult.setOffset(offset); }
Binsearch extends Indexer<String> { @Override protected void completeIndexerSearchResult(String response, IndexerSearchResult indexerSearchResult, AcceptorResult acceptorResult, SearchRequest searchRequest, int offset, Integer limit) { Document doc = Jsoup.parse(response); if (doc.select("table.xMenuT").size() > 0) { Element navigationTable = doc.select("table.xMenuT").get(1); Elements pageLinks = navigationTable.select("a"); boolean hasMore = !pageLinks.isEmpty() && pageLinks.last().text().equals(">"); boolean totalKnown = false; indexerSearchResult.setOffset(searchRequest.getOffset()); int total = searchRequest.getOffset() + 100; if (!hasMore) { total = searchRequest.getOffset() + indexerSearchResult.getSearchResultItems().size(); totalKnown = true; } indexerSearchResult.setHasMoreResults(hasMore); indexerSearchResult.setTotalResults(total); indexerSearchResult.setTotalResultsKnown(totalKnown); } else { indexerSearchResult.setHasMoreResults(false); indexerSearchResult.setTotalResults(0); indexerSearchResult.setTotalResultsKnown(true); } indexerSearchResult.setLimit(limit); indexerSearchResult.setOffset(offset); } }
Binsearch extends Indexer<String> { @Override protected void completeIndexerSearchResult(String response, IndexerSearchResult indexerSearchResult, AcceptorResult acceptorResult, SearchRequest searchRequest, int offset, Integer limit) { Document doc = Jsoup.parse(response); if (doc.select("table.xMenuT").size() > 0) { Element navigationTable = doc.select("table.xMenuT").get(1); Elements pageLinks = navigationTable.select("a"); boolean hasMore = !pageLinks.isEmpty() && pageLinks.last().text().equals(">"); boolean totalKnown = false; indexerSearchResult.setOffset(searchRequest.getOffset()); int total = searchRequest.getOffset() + 100; if (!hasMore) { total = searchRequest.getOffset() + indexerSearchResult.getSearchResultItems().size(); totalKnown = true; } indexerSearchResult.setHasMoreResults(hasMore); indexerSearchResult.setTotalResults(total); indexerSearchResult.setTotalResultsKnown(totalKnown); } else { indexerSearchResult.setHasMoreResults(false); indexerSearchResult.setTotalResults(0); indexerSearchResult.setTotalResultsKnown(true); } indexerSearchResult.setLimit(limit); indexerSearchResult.setOffset(offset); }  }
Binsearch extends Indexer<String> { @Override protected void completeIndexerSearchResult(String response, IndexerSearchResult indexerSearchResult, AcceptorResult acceptorResult, SearchRequest searchRequest, int offset, Integer limit) { Document doc = Jsoup.parse(response); if (doc.select("table.xMenuT").size() > 0) { Element navigationTable = doc.select("table.xMenuT").get(1); Elements pageLinks = navigationTable.select("a"); boolean hasMore = !pageLinks.isEmpty() && pageLinks.last().text().equals(">"); boolean totalKnown = false; indexerSearchResult.setOffset(searchRequest.getOffset()); int total = searchRequest.getOffset() + 100; if (!hasMore) { total = searchRequest.getOffset() + indexerSearchResult.getSearchResultItems().size(); totalKnown = true; } indexerSearchResult.setHasMoreResults(hasMore); indexerSearchResult.setTotalResults(total); indexerSearchResult.setTotalResultsKnown(totalKnown); } else { indexerSearchResult.setHasMoreResults(false); indexerSearchResult.setTotalResults(0); indexerSearchResult.setTotalResultsKnown(true); } indexerSearchResult.setLimit(limit); indexerSearchResult.setOffset(offset); }  @Override NfoResult getNfo(String guid); }
Binsearch extends Indexer<String> { @Override protected void completeIndexerSearchResult(String response, IndexerSearchResult indexerSearchResult, AcceptorResult acceptorResult, SearchRequest searchRequest, int offset, Integer limit) { Document doc = Jsoup.parse(response); if (doc.select("table.xMenuT").size() > 0) { Element navigationTable = doc.select("table.xMenuT").get(1); Elements pageLinks = navigationTable.select("a"); boolean hasMore = !pageLinks.isEmpty() && pageLinks.last().text().equals(">"); boolean totalKnown = false; indexerSearchResult.setOffset(searchRequest.getOffset()); int total = searchRequest.getOffset() + 100; if (!hasMore) { total = searchRequest.getOffset() + indexerSearchResult.getSearchResultItems().size(); totalKnown = true; } indexerSearchResult.setHasMoreResults(hasMore); indexerSearchResult.setTotalResults(total); indexerSearchResult.setTotalResultsKnown(totalKnown); } else { indexerSearchResult.setHasMoreResults(false); indexerSearchResult.setTotalResults(0); indexerSearchResult.setTotalResultsKnown(true); } indexerSearchResult.setLimit(limit); indexerSearchResult.setOffset(offset); }  @Override NfoResult getNfo(String guid);  }