NewsService service = Controller.getDefault().getNewsService();
IFeed feed1 = fModel.getTypesFactory().createFeed(null, new URL("http://www.feed.com"));
IFeed feed2 = fModel.getTypesFactory().createFeed(null, new URL("http://www.feed2.com"));
INews news1 = fModel.getTypesFactory().createNews(null, feed1, new Date());
news1.setLink(new URI("www.link.com"));
INews news2 = fModel.getTypesFactory().createNews(null, feed2, new Date());
news2.setLink(new URI("www.link.com"));
fModel.getTypesFactory().createNews(null, feed1, new Date());
fModel.getTypesFactory().createNews(null, feed2, new Date());
feed1 = fDao.saveFeed(feed1);
feed2 = fDao.saveFeed(feed2);
assertEquals(2, service.getUnreadCount(news1.getFeedReference()));
assertEquals(2, service.getNewCount(news1.getFeedReference()));
assertEquals(2, service.getUnreadCount(news2.getFeedReference()));
assertEquals(2, service.getNewCount(news2.getFeedReference()));
final long feed1ID = feed1.getId();
final long feed2ID = feed2.getId();
final long news1ID = feed1.getNews().get(0).getId();
final long news2ID = feed2.getNews().get(0).getId();
newsListener = new NewsListener() {
public void newsAdded(Set<NewsEvent> events) {
fail("Unexpected Event!");
}
public void newsDeleted(Set<NewsEvent> events) {
fail("Unexpected Event!");
}
public void newsUpdated(Set<NewsEvent> events) {
assertEquals(2, events.size());
for (NewsEvent event : events) {
INews news = event.getEntity();
IFeed parent = news.getFeedReference().resolve();
if (news.getId() == news1ID)
assertEquals(feed1ID, parent.getId());
else if (news.getId() == news2ID)
assertEquals(feed2ID, parent.getId());
else
fail("Unexpected Reference in Event!");
}
}