Search in sources :

Example 1 with SyndEntryImpl

use of com.rometools.rome.feed.synd.SyndEntryImpl in project rssriver by dadoonet.

the class RssToJsonTest method shouldNotHaveRawContent.

@Test
public void shouldNotHaveRawContent() throws Exception {
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(getClass().getResource("/dcrainmaker/rss.xml")));
    assertThat(feed.getEntries().size(), greaterThan(0));
    for (Object o : feed.getEntries()) {
        SyndEntryImpl message = (SyndEntryImpl) o;
        XContentBuilder xcb = toJson(message, null, null, false);
        assertThat(xcb, notNullValue());
        assertThat(xcb.string(), new SubstringMatcher("<p>") {

            @Override
            protected boolean evalSubstringOf(String s) {
                return s.indexOf(substring) < 0;
            }

            @Override
            protected String relationship() {
                return "not containing";
            }
        });
        logger.info(xcb.string());
    }
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SubstringMatcher(org.hamcrest.core.SubstringMatcher) SyndFeedInput(com.rometools.rome.io.SyndFeedInput) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) XmlReader(com.rometools.rome.io.XmlReader) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.Test)

Example 2 with SyndEntryImpl

use of com.rometools.rome.feed.synd.SyndEntryImpl in project rssriver by dadoonet.

the class RomeTest method testGeoLoc.

@Test
public void testGeoLoc() throws Exception {
    SyndFeedInput input = new SyndFeedInput();
    input.setPreserveWireFeed(true);
    SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));
    assertThat(feed, notNullValue());
    assertThat(feed.getEntries().isEmpty(), equalTo(false));
    for (Object o : feed.getEntries()) {
        assertThat(o, instanceOf(SyndEntryImpl.class));
        SyndEntryImpl entry = (SyndEntryImpl) o;
        GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
        assertThat(geoRSSModule, notNullValue());
        Position position = geoRSSModule.getPosition();
        assertThat(position, notNullValue());
        assertThat(position.getLatitude(), equalTo(41.8947384616695));
        assertThat(position.getLongitude(), equalTo(12.4839019775391));
    }
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) Position(com.rometools.modules.georss.geometries.Position) SyndFeedInput(com.rometools.rome.io.SyndFeedInput) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) GeoRSSModule(com.rometools.modules.georss.GeoRSSModule) XmlReader(com.rometools.rome.io.XmlReader) Test(org.junit.Test)

Example 3 with SyndEntryImpl

use of com.rometools.rome.feed.synd.SyndEntryImpl in project rssriver by dadoonet.

the class RssToJsonTest method shouldParseRssGeoInformation.

@Test
public void shouldParseRssGeoInformation() throws Exception {
    final SyndEntryImpl entry = buildEntry();
    final XContentBuilder xContentBuilder = RssToJson.toJson(entry, null, null, true);
    assertThat(xContentBuilder.string(), equalTo(JSON));
}
Also used : SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.Test)

Example 4 with SyndEntryImpl

use of com.rometools.rome.feed.synd.SyndEntryImpl in project rssriver by dadoonet.

the class RssToJsonTest method shouldParseRss.

@Test
public /* this test should be moved somewhere else */
void shouldParseRss() throws Exception {
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));
    assertThat(feed.getEntries().size(), greaterThan(0));
    for (Object o : feed.getEntries()) {
        SyndEntryImpl message = (SyndEntryImpl) o;
        XContentBuilder xcb = toJson(message, null, null, true);
        assertThat(xcb, notNullValue());
    }
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndFeedInput(com.rometools.rome.io.SyndFeedInput) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) XmlReader(com.rometools.rome.io.XmlReader) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.Test)

Example 5 with SyndEntryImpl

use of com.rometools.rome.feed.synd.SyndEntryImpl in project rssriver by dadoonet.

the class RssToJsonTest method buildEntry.

private SyndEntryImpl buildEntry() throws FeedException, IOException {
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));
    return (SyndEntryImpl) feed.getEntries().get(0);
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndFeedInput(com.rometools.rome.io.SyndFeedInput) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) XmlReader(com.rometools.rome.io.XmlReader)

Aggregations

SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)7 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)6 SyndFeedInput (com.rometools.rome.io.SyndFeedInput)5 XmlReader (com.rometools.rome.io.XmlReader)5 Test (org.junit.Test)5 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)4 GeoRSSModule (com.rometools.modules.georss.GeoRSSModule)1 Position (com.rometools.modules.georss.geometries.Position)1 SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)1 ArrayList (java.util.ArrayList)1 SubstringMatcher (org.hamcrest.core.SubstringMatcher)1