news.setLink(new URI("http://www.news.com"));
news.setState(INews.State.READ);
DynamicDAO.save(feed);
UndoStack.getInstance().addOperation(new StickyOperation(Collections.singletonList(news), true));
news.setFlagged(true);
DynamicDAO.save(news);
for (int i = 0; i < 20; i++) {
UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), i % 2 == 0 ? INews.State.UNREAD : INews.State.READ, false));
DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), i % 2 == 0 ? INews.State.UNREAD : INews.State.READ, false, false);
}
int undos = 0;
while (UndoStack.getInstance().isUndoSupported()) {
UndoStack.getInstance().undo();
undos++;
}
assertEquals(true, news.toReference().resolve().isFlagged());
assertEquals(20, undos);
assertEquals(true, UndoStack.getInstance().isRedoSupported());
int redos = 0;
while (UndoStack.getInstance().isRedoSupported()) {
UndoStack.getInstance().redo();
redos++;
}
assertEquals(20, redos);
while (UndoStack.getInstance().isUndoSupported()) {
UndoStack.getInstance().undo();
}
UndoStack.getInstance().addOperation(new StickyOperation(Collections.singletonList(news), false));
news.setFlagged(false);
DynamicDAO.save(news);
undos = 0;
while (UndoStack.getInstance().isUndoSupported()) {