use of org.nzbhydra.fortests.NewznabResponseBuilder in project nzbhydra2 by theotherp.
the class NewznabCheckerTest method shouldCheckCapsWithoutSupport.
@Test
public void shouldCheckCapsWithoutSupport() throws Exception {
NewznabResponseBuilder builder = new NewznabResponseBuilder();
when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&tvdbid=121361"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "somethingElse", 0, 100));
when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&rid=24493"), indexerConfig)).thenReturn(builder.getTestResult(1, 100, "somethingElse", 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, "somethingElse", 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, "somethingElse", 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, "somethingElse", 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, "somethingElse", 0, 100));
CheckCapsResponse checkCapsRespone = testee.checkCaps(indexerConfig);
assertEquals(0, checkCapsRespone.getIndexerConfig().getSupportedSearchIds().size());
verify(indexerWebAccess, times(7)).get(any(), eq(indexerConfig));
}
use of org.nzbhydra.fortests.NewznabResponseBuilder 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));
}
use of org.nzbhydra.fortests.NewznabResponseBuilder in project nzbhydra2 by theotherp.
the class ExternalApiSearchingIntegrationTest method shouldCallNewznabTwice.
@Test
public void shouldCallNewznabTwice() throws Exception {
NewznabResponseBuilder builder = new NewznabResponseBuilder();
String xml1 = builder.getTestResult(1, 100, "indexer1", 0, 150).toXmlString();
String xml2 = builder.getTestResult(101, 150, "indexer1", 100, 150).toXmlString();
String xml3 = builder.getTestResult(1, 0, "indexer2", 0, 0).toXmlString();
webServer.enqueue(new MockResponse().setBody(xml1).setHeader("Content-Type", "application/xml; charset=utf-8"));
webServer.enqueue(new MockResponse().setBody(xml2).setHeader("Content-Type", "application/xml; charset=utf-8"));
webServer.enqueue(new MockResponse().setBody(xml3).setHeader("Content-Type", "application/xml; charset=utf-8"));
NewznabParameters apiCallParameters = new NewznabParameters();
apiCallParameters.setApikey("apikey");
apiCallParameters.setOffset(0);
apiCallParameters.setLimit(100);
apiCallParameters.setT(ActionAttribute.SEARCH);
NewznabXmlRoot apiSearchResult = (NewznabXmlRoot) externalApi.api(apiCallParameters).getBody();
assertThat(apiSearchResult.getRssChannel().getItems().size()).isEqualTo(100);
apiCallParameters.setLimit(100);
apiCallParameters.setOffset(100);
apiSearchResult = (NewznabXmlRoot) externalApi.api(apiCallParameters).getBody();
assertThat(apiSearchResult.getRssChannel().getItems().size()).isEqualTo(50);
}
use of org.nzbhydra.fortests.NewznabResponseBuilder in project nzbhydra2 by theotherp.
the class ExternalApiSearchingIntegrationTest method shouldCallIndexerWithMoreResultsASecondTime.
@Test
public void shouldCallIndexerWithMoreResultsASecondTime() throws Exception {
NewznabResponseBuilder builder = new NewznabResponseBuilder();
String xml1 = builder.getTestResult(1, 2, "indexer1", 0, 3).toXmlString();
String xml2 = builder.getTestResult(3, 3, "indexer1", 2, 3).toXmlString();
String xml3 = builder.getTestResult(1, 0, "indexer2", 0, 0).toXmlString();
webServer.enqueue(new MockResponse().setBody(xml1).setHeader("Content-Type", "application/xml; charset=utf-8"));
webServer.enqueue(new MockResponse().setBody(xml2).setHeader("Content-Type", "application/xml; charset=utf-8"));
webServer.enqueue(new MockResponse().setBody(xml3).setHeader("Content-Type", "application/xml; charset=utf-8"));
NewznabParameters apiCallParameters = new NewznabParameters();
apiCallParameters.setOffset(0);
apiCallParameters.setLimit(2);
apiCallParameters.setT(ActionAttribute.SEARCH);
NewznabXmlRoot apiSearchResult = (NewznabXmlRoot) externalApi.api(apiCallParameters).getBody();
org.assertj.core.api.Assertions.assertThat(apiSearchResult.getRssChannel().getItems().size()).isEqualTo(2);
apiCallParameters.setLimit(100);
apiCallParameters.setOffset(2);
apiSearchResult = (NewznabXmlRoot) externalApi.api(apiCallParameters).getBody();
org.assertj.core.api.Assertions.assertThat(apiSearchResult.getRssChannel().getItems().size()).isEqualTo(1);
org.assertj.core.api.Assertions.assertThat(apiSearchResult.getRssChannel().getItems().get(0).getTitle()).isEqualTo("indexer13");
}
use of org.nzbhydra.fortests.NewznabResponseBuilder in project nzbhydra2 by theotherp.
the class NewznabCheckerTest method shouldSaySoIfNotAllWereChecked.
@Test
public void shouldSaySoIfNotAllWereChecked() throws Exception {
NewznabResponseBuilder builder = new NewznabResponseBuilder();
when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=tvsearch&tvdbid=121361"), 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&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, "Thrones", 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)).thenThrow(new IndexerAccessException("some error"));
CheckCapsResponse checkCapsRespone = testee.checkCaps(indexerConfig);
assertEquals(5, checkCapsRespone.getIndexerConfig().getSupportedSearchIds().size());
assertFalse(checkCapsRespone.isAllCapsChecked());
verify(indexerWebAccess, times(7)).get(any(), eq(indexerConfig));
}
Aggregations