Search in sources :

Example 1 with SubstringMatcher

use of org.hamcrest.core.SubstringMatcher 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)

Aggregations

SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 SyndFeedInput (com.rometools.rome.io.SyndFeedInput)1 XmlReader (com.rometools.rome.io.XmlReader)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 SubstringMatcher (org.hamcrest.core.SubstringMatcher)1 Test (org.junit.Test)1