};
DynamicDAO.addEntityListener(INews.class, newsListener);
/* First Reload */
InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World", "bpasero", null, "mp3");
fController.reload(bookmark, null, new NullProgressMonitor());
assertEquals(1, feedRef.resolve().getNews().size());
assertEquals(1, getUnreadCount(feed));
assertEquals(1, getNewCount(feed));
assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());
assertEquals("Hello World", feedRef.resolve().getNews().get(0).getDescription());
assertEquals("bpasero", feedRef.resolve().getNews().get(0).getAuthor().getName());
/* Set to Unread */
fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
assertEquals(1, updatedCounter[0]);
/* Second Reload - changed Description */
InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "bpasero", null, "mp3");
fController.reload(bookmark, null, new NullProgressMonitor());
assertEquals(1, feedRef.resolve().getNews().size());
assertEquals(1, getUnreadCount(feed));
assertEquals(0, getNewCount(feed));
assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());
assertEquals("Hello World Changed", feedRef.resolve().getNews().get(0).getDescription());
assertEquals(2, updatedCounter[0]);
/* Set to Unread and Reload */
fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
fController.reload(bookmark, null, new NullProgressMonitor());
/* This Reload - added Enclosure */
InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "bpasero", "http://www.download.de", "mp3");
fController.reload(bookmark, null, new NullProgressMonitor());
assertEquals(1, feed.getNews().size());
assertEquals(1, getUnreadCount(feed));
assertEquals(0, getNewCount(feed));
assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());
assertEquals(1, feedRef.resolve().getNews().get(0).getAttachments().size());
assertEquals("http://www.download.de", feedRef.resolve().getNews().get(0).getAttachments().get(0).getLink().toString());
assertEquals(3, updatedCounter[0]);
/* This Reload - Changed Author */
InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "ijuma", "http://www.download.de", "mp3");
oldNewsListener = new NewsAdapter() {
@Override
public void entitiesUpdated(Set<NewsEvent> events) {
assertEquals(1, events.size());
int attachmentsSize = events.iterator().next().getOldNews().getAttachments().size();
assertEquals(1, attachmentsSize);
}
};
DynamicDAO.addEntityListener(INews.class, oldNewsListener);
fController.reload(bookmark, null, new NullProgressMonitor());
DynamicDAO.removeEntityListener(INews.class, oldNewsListener);
assertEquals(1, feedRef.resolve().getNews().size());
assertEquals(1, getUnreadCount(feed));
assertEquals(0, getNewCount(feed));
assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());