Controller.getDefault().reload(sternBm, null, null);
Controller.getDefault().reload(heiseBm, null, null);
Controller.getDefault().reload(golemBm, null, null);
SyncService service = new SyncService();
assertTrue(service.getStatus() == null);
List<SyncItem> items = new ArrayList<SyncItem>();
INews sternNews1 = sternFeed.getNews().get(0);
INews sternNews2 = sternFeed.getNews().get(1);
INews heiseNews1 = heiseFeed.getNews().get(0);
INews heiseNews2 = heiseFeed.getNews().get(1);
INews golemNews1 = golemFeed.getNews().get(0);
INews golemNews2 = golemFeed.getNews().get(1);
SyncItem item = SyncItem.toSyncItem(sternNews1);
item.setStarred();
items.add(item);
item = SyncItem.toSyncItem(heiseNews1);
item.setStarred();
items.add(item);
item = SyncItem.toSyncItem(golemNews1);
item.setStarred();
items.add(item);
item = SyncItem.toSyncItem(sternNews2);
item.addLabel("Foo Bar");
items.add(item);
item = SyncItem.toSyncItem(heiseNews2);
item.addLabel("Foo Bar");
items.add(item);
item = SyncItem.toSyncItem(golemNews2);
item.addLabel("Foo Bar");
item.addLabel("Hello World");
items.add(item);
service.testSync(items);
assertNotNull(service.getStatus());
SyncStatus status = service.getStatus();
assertEquals(6, status.getItemCount());
assertEquals(6, status.getTotalItemCount());
Controller.getDefault().reload(sternBm, null, null);
Controller.getDefault().reload(heiseBm, null, null);
Controller.getDefault().reload(golemBm, null, null);
int counter = 0;
for (INews news : sternFeed.getNews()) {
if (news.getGuid().getValue().equals(sternNews1.getGuid().getValue())) {
if (news.isFlagged())
counter++;
} else if (news.getGuid().getValue().equals(sternNews2.getGuid().getValue())) {
if (news.isFlagged())
counter++;
Set<ILabel> labels = news.getLabels();
for (ILabel label : labels) {
if (label.getName().equals("Foo Bar"))
counter++;
}
}
}
for (INews news : heiseFeed.getNews()) {
if (news.getGuid().getValue().equals(heiseNews1.getGuid().getValue())) {
if (news.isFlagged())
counter++;
} else if (news.getGuid().getValue().equals(heiseNews2.getGuid().getValue())) {
if (news.isFlagged())
counter++;
Set<ILabel> labels = news.getLabels();
for (ILabel label : labels) {
if (label.getName().equals("Foo Bar"))
counter++;
}
}
}
for (INews news : golemFeed.getNews()) {
if (news.getGuid().getValue().equals(golemNews1.getGuid().getValue())) {
if (news.isFlagged())
counter++;
} else if (news.getGuid().getValue().equals(golemNews2.getGuid().getValue())) {
if (news.isFlagged())
counter++;
Set<ILabel> labels = news.getLabels();
for (ILabel label : labels) {
if (label.getName().equals("Foo Bar"))
counter++;
if (label.getName().equals("Hello World"))
counter++;
}
}
}
assertEquals(7, counter);
/* Now remove again and check */
item = SyncItem.toSyncItem(sternNews1);
item.setUnStarred();
items.add(item);
item = SyncItem.toSyncItem(heiseNews1);
item.setUnStarred();
items.add(item);
item = SyncItem.toSyncItem(golemNews1);
item.setUnStarred();
items.add(item);
item = SyncItem.toSyncItem(sternNews2);
item.removeLabel("Foo Bar");
items.add(item);
item = SyncItem.toSyncItem(heiseNews2);
item.removeLabel("Foo Bar");
items.add(item);
item = SyncItem.toSyncItem(golemNews2);
item.removeLabel("Foo Bar");
item.removeLabel("Hello World");
items.add(item);
service.testSync(items);
assertNotNull(service.getStatus());
status = service.getStatus();
assertEquals(6, status.getItemCount());
assertEquals(12, status.getTotalItemCount());
Controller.getDefault().reload(sternBm, null, null);
Controller.getDefault().reload(heiseBm, null, null);