use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot in project nzbhydra2 by theotherp.
the class RssMappingTest method shouldParseResponseFromNzbSu.
@Test
public void shouldParseResponseFromNzbSu() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("nzbSuResponse.xml");
assertEquals(Integer.valueOf(20000), rssRoot.getRssChannel().getNewznabResponse().getTotal());
assertNotNull(rssRoot.getRssChannel().getItems().get(0).getPubDate());
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot in project nzbhydra2 by theotherp.
the class RssMappingTest method shouldParseResponseFromNzbIndex.
@Test
public void shouldParseResponseFromNzbIndex() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("nzbIndexResponse.xml");
assertEquals(100, rssRoot.getRssChannel().getItems().size());
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot in project nzbhydra2 by theotherp.
the class RssMappingTest method testMappingFromXml.
@Test
public void testMappingFromXml() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("newznab_3results.xml");
NewznabXmlChannel channel = rssRoot.getRssChannel();
assertThat(channel.getDescription(), is("indexerName(dot)com Feed"));
assertThat(channel.getLink(), is("https://indexerName.com/"));
assertThat(channel.getLanguage(), is("en-gb"));
assertThat(channel.getWebMaster(), is("admin@indexerName.com (indexerName(dot)com)"));
NewznabXmlResponse newznabResponse = channel.getNewznabResponse();
assertThat(newznabResponse.getOffset(), is(0));
assertThat(newznabResponse.getTotal(), is(1000));
List<NewznabXmlItem> items = channel.getItems();
assertThat(items.size(), is(3));
NewznabXmlItem item = items.get(0);
assertThat(item.getLink(), is("https://indexerName.com/getnzb/eff551fbdb69d6777d5030c209ee5d4b.nzb&i=1692&r=apikey"));
assertThat(item.getPubDate(), is(Instant.ofEpochSecond(1444584857)));
assertThat(item.getDescription(), is("testtitle1"));
assertThat(item.getComments(), is("https://indexerName.com/details/eff551fbdb69d6777d5030c209ee5d4b#comments"));
NewznabXmlGuid rssGuid = item.getRssGuid();
assertThat(rssGuid.getGuid(), is("eff551fbdb69d6777d5030c209ee5d4b"));
assertThat(rssGuid.isPermaLink(), is(false));
NewznabXmlEnclosure enclosure = item.getEnclosure();
assertThat(enclosure.getUrl(), is("https://indexerName.com/getnzb/eff551fbdb69d6777d5030c209ee5d4b.nzb&i=1692&r=apikey"));
assertThat(enclosure.getLength(), is(2893890900L));
List<NewznabAttribute> attributes = item.getNewznabAttributes();
assertThat(attributes.size(), is(6));
assertThat(attributes.get(0).getName(), is("category"));
assertThat(attributes.get(0).getValue(), is("7000"));
assertThat(attributes.get(2).getName(), is("size"));
assertThat(attributes.get(2).getValue(), is("2893890900"));
assertThat(attributes.get(3).getName(), is("guid"));
assertThat(attributes.get(3).getValue(), is("eff551fbdb69d6777d5030c209ee5d4b"));
assertThat(attributes.get(4).getName(), is("poster"));
assertThat(attributes.get(4).getValue(), is("chuck@norris.com"));
assertThat(attributes.get(5).getName(), is("group"));
assertThat(attributes.get(5).getValue(), is("alt.binaries.mom"));
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot in project nzbhydra2 by theotherp.
the class DevIndexerTest method testGeneration.
@Test
public void testGeneration() throws Exception {
Xml xml = testee.getAndStoreResultToDatabase(URI.create("http://127.0.01/duplicatesandtitlegroups"), null);
NewznabXmlRoot root = (NewznabXmlRoot) xml;
System.out.println(root);
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot in project nzbhydra2 by theotherp.
the class IndexerWebAccessTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
String xml = "<?xml version=\"1.0\" ?>\n" + "<metadata>\n" + "</metadata>";
when(webAccessMock.callUrl(anyString(), headersCaptor.capture(), timeoutCaptor.capture())).thenReturn(xml);
BaseConfig baseConfig = new BaseConfig();
baseConfig.setSearching(searchingConfigMock);
when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
when(searchingConfigMock.getUserAgent()).thenReturn(Optional.of("globalUa"));
when(searchingConfigMock.getTimeout()).thenReturn(100);
indexerConfig.setTimeout(10);
indexerConfig.setUserAgent("indexerUa");
when(unmarshallerMock.unmarshal(any())).thenReturn(new NewznabXmlRoot());
}
Aggregations