Search in sources :

Example 1 with IndexerSearchResult

use of org.nzbhydra.searching.IndexerSearchResult in project nzbhydra2 by theotherp.

the class BinsearchTest method shouldRecognizeIfSingleResultPage.

@Test
public void shouldRecognizeIfSingleResultPage() throws Exception {
    SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
    String html = Resources.toString(Resources.getResource(BinsearchTest.class, "/org/nzbhydra/mapping/binsearch_singlepage.html"), Charsets.UTF_8);
    IndexerSearchResult indexerSearchResult = new IndexerSearchResult(testee, "");
    List<SearchResultItem> items = new ArrayList<>();
    for (int i = 0; i < 24; i++) {
        items.add(new SearchResultItem());
    }
    indexerSearchResult.setSearchResultItems(items);
    testee.completeIndexerSearchResult(html, indexerSearchResult, null, searchRequest);
    assertThat(indexerSearchResult.getOffset(), is(0));
    assertThat(indexerSearchResult.getLimit(), is(100));
    assertThat(indexerSearchResult.getTotalResults(), is(24));
    assertThat(indexerSearchResult.isTotalResultsKnown(), is(true));
    assertThat(indexerSearchResult.isHasMoreResults(), is(false));
}
Also used : SearchRequest(org.nzbhydra.searching.searchrequests.SearchRequest) SearchResultItem(org.nzbhydra.searching.SearchResultItem) ArrayList(java.util.ArrayList) IndexerSearchResult(org.nzbhydra.searching.IndexerSearchResult) Test(org.junit.Test)

Example 2 with IndexerSearchResult

use of org.nzbhydra.searching.IndexerSearchResult in project nzbhydra2 by theotherp.

the class BinsearchTest method shouldRecognizeIfMoreResultsAvailable.

@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);
    assertThat(indexerSearchResult.isTotalResultsKnown(), is(false));
    assertThat(indexerSearchResult.isHasMoreResults(), is(true));
}
Also used : SearchRequest(org.nzbhydra.searching.searchrequests.SearchRequest) IndexerSearchResult(org.nzbhydra.searching.IndexerSearchResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 IndexerSearchResult (org.nzbhydra.searching.IndexerSearchResult)2 SearchRequest (org.nzbhydra.searching.searchrequests.SearchRequest)2 ArrayList (java.util.ArrayList)1 SearchResultItem (org.nzbhydra.searching.SearchResultItem)1