Search in sources :

Example 1 with CapsSearch

use of org.nzbhydra.mapping.newznab.caps.CapsSearch in project nzbhydra2 by theotherp.

the class NewznabCheckerTest method shouldCheckCaps.

@Test
public void shouldCheckCaps() throws Exception {
    NewznabResponseBuilder builder = new NewznabResponseBuilder();
    NewznabXmlRoot thronesResult = builder.getTestResult(1, 100, "Thrones", 0, 100);
    thronesResult.getRssChannel().setGenerator("nzedb");
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&tvdbid=121361"), indexerConfig)).thenReturn(thronesResult);
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&rid=24493"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "Thrones", 0, 100));
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&tvmazeid=82"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "Thrones", 0, 100));
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&traktid=1390"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "GOT", 0, 100));
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=movie&tmdbid=1399"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "Avengers", 0, 100));
    when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=movie&imdbid=0848228"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "Avengers", 0, 100));
    capsRoot.getSearching().setAudioSearch(new CapsSearch("yes", "q"));
    CheckCapsResponse checkCapsRespone = testee.checkCaps(indexerConfig);
    assertEquals(6, checkCapsRespone.getIndexerConfig().getSupportedSearchIds().size());
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(TVDB));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(TVRAGE));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(TVMAZE));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(TRAKT));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(IMDB));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchIds().contains(TMDB));
    assertEquals(3, checkCapsRespone.getIndexerConfig().getSupportedSearchTypes().size());
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchTypes().contains(ActionAttribute.AUDIO));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchTypes().contains(ActionAttribute.TVSEARCH));
    assertTrue(checkCapsRespone.getIndexerConfig().getSupportedSearchTypes().contains(ActionAttribute.MOVIE));
    assertEquals(BackendType.NZEDB, checkCapsRespone.getIndexerConfig().getBackend());
    assertTrue(checkCapsRespone.isAllCapsChecked());
    verify(indexerWebAccess, times(7)).get(any(), eq(indexerConfig));
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabResponseBuilder(org.nzbhydra.fortests.NewznabResponseBuilder) URI(java.net.URI) CapsSearch(org.nzbhydra.mapping.newznab.caps.CapsSearch) BinsearchTest(org.nzbhydra.indexers.BinsearchTest) Test(org.junit.Test)

Aggregations

URI (java.net.URI)1 Test (org.junit.Test)1 NewznabResponseBuilder (org.nzbhydra.fortests.NewznabResponseBuilder)1 BinsearchTest (org.nzbhydra.indexers.BinsearchTest)1 CapsSearch (org.nzbhydra.mapping.newznab.caps.CapsSearch)1 NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)1