@Test public void shouldAccountForRejectedResults() throws Exception { List<NewznabXmlItem> items = Arrays.asList( RssItemBuilder.builder("title1").build(), RssItemBuilder.builder("title2").build(), RssItemBuilder.builder("title3").build(), RssItemBuilder.builder("title4").build(), RssItemBuilder.builder("title5").build() ); NewznabXmlRoot root = RssBuilder.builder().items(items).newznabResponse(100, 105).build(); when(indexerWebAccessMock.get(any(), eq(testee.config), any())).thenReturn(root); when(resultAcceptorMock.acceptResults(any(), any(), any())).thenAnswer(new Answer<AcceptorResult>() { @Override public AcceptorResult answer(InvocationOnMock invocation) throws Throwable { List<SearchResultItem> argument = invocation.getArgument(0); HashMultiset<String> reasonsForRejection = HashMultiset.create(); reasonsForRejection.add("some reason", 2); return new AcceptorResult(argument.subList(0, 3), reasonsForRejection); } }); IndexerSearchResult indexerSearchResult = testee.searchInternal(new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100), 0, 100); assertThat(indexerSearchResult.getSearchResultItems().size(), is(3)); assertThat(indexerSearchResult.getTotalResults(), is(105)); assertThat(indexerSearchResult.isHasMoreResults(), is(false)); assertThat(indexerSearchResult.isTotalResultsKnown(), is(true)); }
@Override protected List<SearchResultItem> getSearchResultItems(Xml rssRoot, SearchRequest searchRequest) { List<SearchResultItem> searchResultItems = new ArrayList<>(); final NewznabXmlRoot newznabXmlRoot = (NewznabXmlRoot) rssRoot; checkForTooManyResults(searchRequest, newznabXmlRoot); for (NewznabXmlItem item : newznabXmlRoot.getRssChannel().getItems()) { try { SearchResultItem searchResultItem = createSearchResultItem(item); searchResultItems.add(searchResultItem); } catch (NzbHydraException e) { } } return searchResultItems; }
Newznab extends Indexer<Xml> { @Override protected List<SearchResultItem> getSearchResultItems(Xml rssRoot, SearchRequest searchRequest) { List<SearchResultItem> searchResultItems = new ArrayList<>(); final NewznabXmlRoot newznabXmlRoot = (NewznabXmlRoot) rssRoot; checkForTooManyResults(searchRequest, newznabXmlRoot); for (NewznabXmlItem item : newznabXmlRoot.getRssChannel().getItems()) { try { SearchResultItem searchResultItem = createSearchResultItem(item); searchResultItems.add(searchResultItem); } catch (NzbHydraException e) { } } return searchResultItems; } }
Newznab extends Indexer<Xml> { @Override protected List<SearchResultItem> getSearchResultItems(Xml rssRoot, SearchRequest searchRequest) { List<SearchResultItem> searchResultItems = new ArrayList<>(); final NewznabXmlRoot newznabXmlRoot = (NewznabXmlRoot) rssRoot; checkForTooManyResults(searchRequest, newznabXmlRoot); for (NewznabXmlItem item : newznabXmlRoot.getRssChannel().getItems()) { try { SearchResultItem searchResultItem = createSearchResultItem(item); searchResultItems.add(searchResultItem); } catch (NzbHydraException e) { } } return searchResultItems; }  }
Newznab extends Indexer<Xml> { @Override protected List<SearchResultItem> getSearchResultItems(Xml rssRoot, SearchRequest searchRequest) { List<SearchResultItem> searchResultItems = new ArrayList<>(); final NewznabXmlRoot newznabXmlRoot = (NewznabXmlRoot) rssRoot; checkForTooManyResults(searchRequest, newznabXmlRoot); for (NewznabXmlItem item : newznabXmlRoot.getRssChannel().getItems()) { try { SearchResultItem searchResultItem = createSearchResultItem(item); searchResultItems.add(searchResultItem); } catch (NzbHydraException e) { } } return searchResultItems; }  @Override NfoResult getNfo(String guid); }
Newznab extends Indexer<Xml> { @Override protected List<SearchResultItem> getSearchResultItems(Xml rssRoot, SearchRequest searchRequest) { List<SearchResultItem> searchResultItems = new ArrayList<>(); final NewznabXmlRoot newznabXmlRoot = (NewznabXmlRoot) rssRoot; checkForTooManyResults(searchRequest, newznabXmlRoot); for (NewznabXmlItem item : newznabXmlRoot.getRssChannel().getItems()) { try { SearchResultItem searchResultItem = createSearchResultItem(item); searchResultItems.add(searchResultItem); } catch (NzbHydraException e) { } } return searchResultItems; }  @Override NfoResult getNfo(String guid);  }