Search in sources :

Example 36 with NewznabXmlRoot

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());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) Test(org.junit.Test)

Example 37 with NewznabXmlRoot

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());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) Test(org.junit.Test)

Example 38 with NewznabXmlRoot

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"));
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabAttribute(org.nzbhydra.mapping.newznab.xml.NewznabAttribute) NewznabXmlItem(org.nzbhydra.mapping.newznab.xml.NewznabXmlItem) NewznabXmlChannel(org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel) NewznabXmlResponse(org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse) Test(org.junit.Test)

Example 39 with NewznabXmlRoot

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);
}
Also used : Xml(org.nzbhydra.mapping.newznab.xml.Xml) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) Test(org.junit.Test)

Example 40 with NewznabXmlRoot

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());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseConfig(org.nzbhydra.config.BaseConfig) Before(org.junit.Before)

Aggregations

NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)41 Test (org.junit.Test)30 MockResponse (okhttp3.mockwebserver.MockResponse)12 NewznabXmlItem (org.nzbhydra.mapping.newznab.xml.NewznabXmlItem)11 AbstractConfigReplacingTest (org.nzbhydra.tests.AbstractConfigReplacingTest)10 NewznabAttribute (org.nzbhydra.mapping.newznab.xml.NewznabAttribute)8 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ArrayList (java.util.ArrayList)5 Dispatcher (okhttp3.mockwebserver.Dispatcher)4 NewznabXmlChannel (org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel)4 NzbhydraMockMvcTest (org.nzbhydra.tests.NzbhydraMockMvcTest)4 URI (java.net.URI)3 NewznabResponseBuilder (org.nzbhydra.fortests.NewznabResponseBuilder)3 NewznabParameters (org.nzbhydra.mapping.newznab.NewznabParameters)3 NewznabXmlEnclosure (org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure)3 NewznabXmlGuid (org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Matcher (java.util.regex.Matcher)2 NewznabXmlResponse (org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse)2