INews currentNews = fFactory.createNews(null, feed, new Date());
currentNews.setInReplyTo(feed.getLink().toString());
currentNews.setGuid(fFactory.createGuid(currentNews, "tag:google.com/foo", true));
SyncItem item = SyncItem.toSyncItem(filter, currentNews);
assertNull(item);
filter.addAction(fFactory.createFilterAction(MarkReadNewsAction.ID));
item = SyncItem.toSyncItem(filter, currentNews);
assertTrue(item.isMarkedRead());
assertFalse(item.isMarkedUnread());
assertFalse(item.isStarred());
assertFalse(item.isUnStarred());
assertTrue(item.getAddedLabels().isEmpty());
assertTrue(item.getRemovedLabels().isEmpty());
filter.addAction(fFactory.createFilterAction(MarkStickyNewsAction.ID));
item = SyncItem.toSyncItem(filter, currentNews);
assertTrue(item.isMarkedRead());
assertFalse(item.isMarkedUnread());
assertTrue(item.isStarred());
assertFalse(item.isUnStarred());
assertTrue(item.getAddedLabels().isEmpty());
assertTrue(item.getRemovedLabels().isEmpty());
filter.addAction(fFactory.createFilterAction(MarkUnreadNewsAction.ID));
item = SyncItem.toSyncItem(filter, currentNews);
assertFalse(item.isMarkedRead());
assertTrue(item.isMarkedUnread());
assertTrue(item.isStarred());
assertFalse(item.isUnStarred());
assertTrue(item.getAddedLabels().isEmpty());
assertTrue(item.getRemovedLabels().isEmpty());
IFilterAction action = fFactory.createFilterAction(LabelNewsAction.ID);
action.setData(label1.getId());
filter.addAction(action);
item = SyncItem.toSyncItem(filter, currentNews);
assertFalse(item.isMarkedRead());
assertTrue(item.isMarkedUnread());
assertTrue(item.isStarred());
assertFalse(item.isUnStarred());
assertEquals(1, item.getAddedLabels().size());
assertEquals("Foo", item.getAddedLabels().get(0));
assertTrue(item.getRemovedLabels().isEmpty());
action = fFactory.createFilterAction(LabelNewsAction.ID);
action.setData(label2.getId());
filter.addAction(action);
item = SyncItem.toSyncItem(filter, currentNews);
assertFalse(item.isMarkedRead());
assertTrue(item.isMarkedUnread());
assertTrue(item.isStarred());
assertFalse(item.isUnStarred());
assertEquals(2, item.getAddedLabels().size());
assertEquals("Foo", item.getAddedLabels().get(0));
assertEquals("Bar", item.getAddedLabels().get(1));
assertTrue(item.getRemovedLabels().isEmpty());
action = fFactory.createFilterAction(DeleteNewsAction.ID);
filter.addAction(action);
item = SyncItem.toSyncItem(filter, currentNews);
assertTrue(item.isMarkedRead());
assertFalse(item.isMarkedUnread());
assertTrue(item.isStarred());
assertFalse(item.isUnStarred());
assertEquals(2, item.getAddedLabels().size());
assertEquals("Foo", item.getAddedLabels().get(0));
assertEquals("Bar", item.getAddedLabels().get(1));
assertTrue(item.getRemovedLabels().isEmpty());
}