use of org.nzbhydra.mapping.newznab.caps.CapsRoot in project nzbhydra2 by theotherp.
the class NewznabCheckerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
indexerConfig = new IndexerConfig();
indexerConfig.setHost("http://127.0.0.1:1234");
indexerConfig.setApiKey("apikey");
when(searchingConfig.getTimeout()).thenReturn(1);
when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
when(baseConfig.getSearching()).thenReturn(searchingConfig);
capsRoot = new CapsRoot();
capsRoot.setSearching(new CapsSearching());
CapsLimits capsLimits = new CapsLimits(200, 100);
capsRoot.setLimits(capsLimits);
when(indexerWebAccess.get(new URI("http://127.0.0.1:1234/api?apikey=apikey&t=caps"), indexerConfig)).thenReturn(capsRoot);
testee.PAUSE_BETWEEN_CALLS = 0;
}
use of org.nzbhydra.mapping.newznab.caps.CapsRoot in project nzbhydra2 by theotherp.
the class RssCapsMappingTest method shouldGenerateCorrectXml.
@Test
public void shouldGenerateCorrectXml() throws JsonProcessingException, JAXBException {
CapsRoot caps = new CapsRoot();
List<CapsCategory> categories = new ArrayList<>();
CapsCategory capsCategory = new CapsCategory(1000, "1000");
List<CapsCategory> subCats = new ArrayList<>();
subCats.add(new CapsCategory(1010, "1010"));
capsCategory.setSubCategories(subCats);
caps.getCategories().getCategories().add(capsCategory);
StringWriter writer = new StringWriter();
StreamResult streamResult = new StreamResult(writer);
jaxb2Marshaller.marshal(caps, streamResult);
assertThat(writer.toString(), containsString("<categories>\n" + " <category id=\"1000\" name=\"1000\">\n" + " <subcat id=\"1010\" name=\"1010\"/>\n" + " </category>\n" + " </categories>"));
}
use of org.nzbhydra.mapping.newznab.caps.CapsRoot in project nzbhydra2 by theotherp.
the class NewznabChecker method setSupportedSearchTypesAndIndexerCategoryMapping.
public IndexerCategoryConfig setSupportedSearchTypesAndIndexerCategoryMapping(IndexerConfig indexerConfig, int timeout) throws IndexerAccessException {
List<IdType> supportedSearchIds = indexerConfig.getSupportedSearchIds();
List<ActionAttribute> supportedSearchTypes = new ArrayList<>();
if (supportedSearchIds.contains(IdType.TVDB) || supportedSearchIds.contains(IdType.TVRAGE) || supportedSearchIds.contains(IdType.TVMAZE) || supportedSearchIds.contains(IdType.TRAKT)) {
supportedSearchTypes.add(ActionAttribute.TVSEARCH);
}
if (supportedSearchIds.contains(IdType.IMDB) || supportedSearchIds.contains(IdType.TMDB)) {
supportedSearchTypes.add(ActionAttribute.MOVIE);
}
URI uri = getBaseUri(indexerConfig).queryParam("t", "caps").build().toUri();
CapsRoot capsRoot = indexerWebAccess.get(uri, indexerConfig);
if (capsRoot.getSearching().getAudioSearch() != null) {
supportedSearchTypes.add(ActionAttribute.AUDIO);
}
if (capsRoot.getSearching().getBookSearch() != null) {
supportedSearchTypes.add(ActionAttribute.BOOK);
}
indexerConfig.setSupportedSearchTypes(supportedSearchTypes);
IndexerCategoryConfig categoryConfig = new IndexerCategoryConfig();
List<CapsCategory> categories = readAndConvertCategories(capsRoot, categoryConfig);
setCategorySpecificMappings(categoryConfig, categories);
return categoryConfig;
}
Aggregations