use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldNotGetInfosIfAtLeastOneProvidedIsSupported.
@Test
public void shouldNotGetInfosIfAtLeastOneProvidedIsSupported() throws Exception {
testee.config = new IndexerConfig();
testee.config.setSupportedSearchIds(Lists.newArrayList(IdType.IMDB));
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.getIdentifiers().put(IdType.IMDB, "imdbId");
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://www.indexerName.com/api");
builder = testee.extendQueryUrlWithSearchIds(searchRequest, builder);
MultiValueMap<String, String> params = builder.build().getQueryParams();
assertTrue(params.containsKey("imdbid"));
assertEquals(1, params.size());
verify(infoProviderMock, never()).convert(anyString(), any(IdType.class));
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldThrowProgramErrorCodeException.
@Test(expected = IndexerProgramErrorException.class)
public void shouldThrowProgramErrorCodeException() throws Exception {
doReturn(new NewznabXmlError("200", "Whatever")).when(testee).getAndStoreResultToDatabase(any(), eq(Xml.class), eq(IndexerApiAccessType.SEARCH));
doNothing().when(testee).handleFailure(errorMessageCaptor.capture(), disabledPermanentlyCaptor.capture(), any(IndexerApiAccessType.class), any(), indexerApiAccessResultCaptor.capture());
testee.searchInternal(new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100), 0, 100);
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class SearcherUnitTest method shouldReturnNewestFirst.
@Test
public void shouldReturnNewestFirst() throws Exception {
when(pickingResultMock.getSelectedIndexers()).thenReturn(Arrays.asList(indexer1, indexer2));
Instant now = Instant.now();
IndexerSearchResult indexer1results = mockIndexerSearchResult(0, 100, true, 100, indexer1);
indexer1results.getSearchResultItems().get(0).setPubDate(now);
when(indexer1.search(any(), anyInt(), anyInt())).thenReturn(indexer1results);
IndexerSearchResult indexer2results = mockIndexerSearchResult(0, 100, true, 100, indexer2);
indexer2results.getSearchResultItems().get(0).setPubDate(now.minus(1, ChronoUnit.MINUTES));
when(indexer2.search(any(), anyInt(), anyInt())).thenReturn(indexer2results);
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 2);
searchRequest.setTitle("some title so it will be found in the search request cache");
SearchResult result = searcher.search(searchRequest);
List<SearchResultItem> foundResults = result.getSearchResultItems();
assertThat(foundResults.size(), is(2));
assertThat(foundResults.get(0).getTitle(), is("item0"));
assertThat(foundResults.get(0).getIndexer(), is(indexer1));
assertThat(foundResults.get(1).getTitle(), is("item0"));
assertThat(foundResults.get(1).getIndexer(), is(indexer2));
}
Aggregations