use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldUseDifferentExclusionFormatForNzedbAndOmgWtf.
@Test
public void shouldUseDifferentExclusionFormatForNzedbAndOmgWtf() throws Exception {
testee.config.setBackend(BackendType.NZEDB);
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());
testee.config.setBackend(BackendType.NEWZNAB);
testee.config.setHost("http://www.OMGwtfnzbs.com");
searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setQuery("q");
searchRequest.getInternalData().setForbiddenWords(Lists.newArrayList("a", "b", "c"));
assertEquals(UriComponentsBuilder.fromHttpUrl("http://www.OMGwtfnzbs.com/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://www.OMGwtfnzbs.com/api?t=search&extended=1&q=aquery !a,!b,!c").build(), testee.buildSearchUrl(searchRequest, null, null).build());
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldThrowErrorCodeWhen100ApiHitLimits.
@Test(expected = IndexerErrorCodeException.class)
public void shouldThrowErrorCodeWhen100ApiHitLimits() throws Exception {
doReturn(new NewznabXmlError("100", "Daily Hits Limit Reached\"")).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 NewznabTest method shouldUseAuthorAndTitleIfBookSearchSupported.
@Test
public void shouldUseAuthorAndTitleIfBookSearchSupported() throws Exception {
testee.config = new IndexerConfig();
baseConfig.getSearching().setGenerateQueries(SearchSourceRestriction.BOTH);
testee.config.setHost("http://www.indexer.com");
testee.config.setSupportedSearchTypes(Arrays.asList(ActionAttribute.BOOK));
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.BOOK, 0, 100);
searchRequest.setAuthor("author");
searchRequest.setTitle("title");
assertEquals(UriComponentsBuilder.fromHttpUrl("http://www.indexer.com/api?t=book&extended=1&q=title&title=title&author=author").build(), testee.buildSearchUrl(searchRequest, null, null).build());
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldGenerateQueryIfNecessaryAndAllowed.
@Test
public void shouldGenerateQueryIfNecessaryAndAllowed() throws Exception {
testee.config = new IndexerConfig();
baseConfig.getSearching().setGenerateQueries(SearchSourceRestriction.BOTH);
testee.config.setHost("http://www.indexer.com");
testee.config.setSupportedSearchIds(Collections.emptyList());
SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.getIdentifiers().put(IdType.IMDB, "imdbId");
when(infoProviderMock.canConvert(any(), any())).thenReturn(false);
MediaInfo mediaInfo = new MediaInfo();
mediaInfo.setTitle("someMovie");
when(infoProviderMock.convert("imdbId", IdType.IMDB)).thenReturn(mediaInfo);
assertEquals(UriComponentsBuilder.fromHttpUrl("http://www.indexer.com/api?t=search&extended=1&imdbid=imdbId&q=someMovie").build(), testee.buildSearchUrl(searchRequest, null, null).build());
// Should use title if provided
searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
searchRequest.setTitle("anotherTitle");
UriComponents actual = testee.buildSearchUrl(searchRequest, null, null).build();
assertEquals(UriComponentsBuilder.fromHttpUrl("http://www.indexer.com/api?t=search&extended=1&q=anotherTitle").build(), actual);
}
use of org.nzbhydra.searching.searchrequests.SearchRequest in project nzbhydra2 by theotherp.
the class NewznabTest method shouldNotUseMovieWithoutIdentifiers.
@Test
public void shouldNotUseMovieWithoutIdentifiers() throws Exception {
SearchRequest request = new SearchRequest(SearchSource.INTERNAL, SearchType.MOVIE, 0, 100);
String uri = testee.buildSearchUrl(request, 0, 100).toUriString();
assertThat(uri, containsString("t=search"));
request = new SearchRequest(SearchSource.INTERNAL, SearchType.MOVIE, 0, 100);
request.getIdentifiers().put(IdType.IMDB, "123");
testee.config.getSupportedSearchIds().add(IdType.IMDB);
testee.config.getSupportedSearchTypes().add(ActionAttribute.MOVIE);
uri = testee.buildSearchUrl(request, 0, 100).toUriString();
assertThat(uri, containsString("t=movie"));
assertThat(uri, containsString("imdbid=123"));
}
Aggregations