use of org.nzbhydra.mediainfo.MediaInfo in project nzbhydra2 by theotherp.
the class ExternalApiSearchingIntegrationTest method shouldConvertProvidedIdentifier.
@Test
public void shouldConvertProvidedIdentifier() throws Exception {
prepareIndexerWithOneResponse();
searchModuleProvider.getIndexers().get(0).getConfig().setSupportedSearchIds(Arrays.asList(IdType.IMDB));
when(infoProvider.convert(anyMap())).thenReturn(new MediaInfo(new MovieInfo("tt1234", null, null, 0, null)));
when(infoProvider.canConvertAny(anySet(), anySet())).thenReturn(true);
NewznabXmlRoot root = (NewznabXmlRoot) externalApi.api(NewznabParameters.builder().tmdbid("abcd").t(ActionAttribute.MOVIE).apikey("apikey").build()).getBody();
RecordedRequest request = webServer.takeRequest(2, TimeUnit.SECONDS);
assertThat(request.getRequestUrl().queryParameter("imdbid")).isEqualTo("1234");
assertThat(root.getRssChannel().getNewznabResponse().getTotal()).isEqualTo(1);
assertThat(root.getRssChannel().getItems().size()).isEqualTo(1);
}
use of org.nzbhydra.mediainfo.MediaInfo in project nzbhydra2 by theotherp.
the class IndexerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(indexerMock.getIndexerEntity()).thenReturn(indexerEntityMock);
when(indexerMock.getConfig()).thenReturn(indexerConfig);
when(indexerEntityMock.getName()).thenReturn("indexerName");
when(indexerMock.getName()).thenReturn("indexerName");
testee.indexer = indexerEntityMock;
testee.config = indexerConfig;
indexerConfig.setTimeout(1);
baseConfig = new BaseConfig();
when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
baseConfig.getSearching().setIdFallbackToQueryGeneration(SearchSourceRestriction.BOTH);
when(resultAcceptor.acceptResults(anyList(), any(), any())).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new AcceptorResult(invocation.getArgument(0), HashMultiset.create());
}
});
when(infoProviderMock.convert(anyString(), any())).thenReturn(new MediaInfo(new TvInfo("tvdbid", "tvrageid", "tvmazeid", "title", 2017, "")));
testee = spy(testee);
}
use of org.nzbhydra.mediainfo.MediaInfo 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"));
}
Aggregations