savedNews.setTitle("News Title Updated #1");
List<INews> newsList = new ArrayList<INews>();
newsList.add(savedNews);
NewsListener newsListener = new NewsAdapter() {
@Override
public void newsUpdated(Set<NewsEvent> events) {
assertEquals(1, events.size());
NewsEvent event = events.iterator().next();
assertEquals(true, event.getEntity().equalsId(savedNews));
assertEquals(State.UNREAD, event.getOldNews().getState());
assertEquals(State.UNREAD, event.getEntity().getState());
}
};
fModel.addNewsListener(newsListener);
try {
newsList = fAppLayer.saveNews(newsList);
} finally {
fModel.removeNewsListener(newsListener);
}
newsListener = new NewsAdapter() {
@Override
public void newsUpdated(Set<NewsEvent> events) {
assertEquals(1, events.size());
NewsEvent event = events.iterator().next();
assertEquals(savedNews.getId().longValue(), event.getEntity().getId());