use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class BinsearchTest method shouldBuildSimpleQuery.
@Test
public void shouldBuildSimpleQuery() throws IndexerSearchAbortedException {
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setQuery("query");
UriComponentsBuilder builder = testee.buildSearchUrl(searchRequest, 0, 100);
assertThat(builder.toUriString(), is("https://www.binsearch.info/?adv_col=on&postdate=date&adv_sort=date&min=0&max=100&q=query"));
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class IndexerTest method shouldGenerateQuery.
@Test
public void shouldGenerateQuery() throws IndexerSearchAbortedException {
baseConfig.getSearching().setGenerateQueries(SearchSourceRestriction.BOTH);
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
Map<IdType, String> identifiers = new HashMap<>();
identifiers.put(IdType.IMDB, "123");
searchRequest.setIdentifiers(identifiers);
String query = testee.generateQueryIfApplicable(searchRequest, "query");
assertThat(query, is("title"));
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class IndexerTest method shouldSanitizeQuery.
@Test
public void shouldSanitizeQuery() throws IndexerSearchAbortedException, InfoProviderException {
when(infoProviderMock.convert(anyString(), any())).thenReturn(new MediaInfo(new TvInfo("tvdbid", "tvrageid", "tvmazeid", "title()':", 2017, "")));
baseConfig.getSearching().setGenerateQueries(SearchSourceRestriction.BOTH);
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
Map<IdType, String> identifiers = new HashMap<>();
identifiers.put(IdType.IMDB, "123");
searchRequest.setIdentifiers(identifiers);
String query = testee.generateQueryIfApplicable(searchRequest, "query");
assertThat(query, is("title"));
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldAddExcludedAndRequiredWordsToQuery.
@Test
public void shouldAddExcludedAndRequiredWordsToQuery() throws Exception {
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setQuery("q");
searchRequest.getInternalData().setForbiddenWords(Lists.newArrayList("a", "b", "c"));
assertEquals(UriComponentsBuilder.fromHttpUrl("http://127.0.0.1:1234/api?t=search&extended=1&q=q --a --b --c").build(), testee.buildSearchUrl(searchRequest, null, null).build());
searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setQuery("aquery");
searchRequest.getInternalData().setForbiddenWords(Lists.newArrayList("a", "b", "c"));
assertEquals(UriComponentsBuilder.fromHttpUrl("http://127.0.0.1:1234/api?t=search&extended=1&q=aquery --a --b --c").build(), testee.buildSearchUrl(searchRequest, null, null).build());
searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setQuery("q");
searchRequest.getInternalData().setForbiddenWords(Lists.newArrayList("a", "b", "c"));
searchRequest.getInternalData().setRequiredWords(Lists.newArrayList("x", "y", "z"));
assertEquals(UriComponentsBuilder.fromHttpUrl("http://127.0.0.1:1234/api?t=search&extended=1&q=q x y z --a --b --c").build(), testee.buildSearchUrl(searchRequest, null, null).build());
searchRequest.getCategory().getForbiddenWords().add("catforbidden");
searchRequest.getCategory().getRequiredWords().add("catrequired");
baseConfig.getSearching().setForbiddenWords(Lists.newArrayList("globalforbidden"));
baseConfig.getSearching().setRequiredWords(Lists.newArrayList("globalrequired"));
assertEquals(UriComponentsBuilder.fromHttpUrl("http://127.0.0.1:1234/api?t=search&extended=1&q=q x y z globalrequired catrequired --a --b --c --globalforbidden --catforbidden").build(), testee.buildSearchUrl(searchRequest, null, null).build());
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldThrowErrorCodeThatsNotMyFaultException.
@Test(expected = IndexerErrorCodeException.class)
public void shouldThrowErrorCodeThatsNotMyFaultException() throws Exception {
doReturn(new NewznabXmlError("123", "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);
}
Aggregations