use of org.mamute.infra.rss.write.RssFeedFactory in project mamute by caelum.
the class RssFeedFactoryTest method should_generate_feed.
@Test
public void should_generate_feed() throws IOException {
DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
QuestionBuilder builder = new QuestionBuilder();
DateTimeUtils.setCurrentMillisFixed(100);
User user1 = user("author1", "author@email");
user1.setPhotoUri(new URL("http://imagemsuser1.com"));
Question question1 = builder.withAuthor(user1).withTitle("first question").withDescription("question").withId(1l).build();
User user2 = user("author2", "author@email");
user2.setPhotoUri(new URL("http://imagemsuser2.com"));
Question question2 = builder.withId(2l).withTitle("second question").withAuthor(user2).build();
ByteArrayOutputStream output = new ByteArrayOutputStream();
rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output, "title", "description");
output.close();
String xml = new String(output.toByteArray());
assertTrue(xml.contains("first question"));
assertTrue(xml.contains("second question"));
assertTrue(xml.contains("http://imagemsuser1.com"));
assertTrue(xml.contains("http://imagemsuser2.com"));
DateTimeUtils.setCurrentMillisSystem();
}
Aggregations