Package org.rssowl.ui.internal.services.SyncService

Examples of org.rssowl.ui.internal.services.SyncService.SyncStatus


    service.testSync(syncItems);

    /* Assert Status */
    assertNotNull(service.getStatus());
    SyncStatus status = service.getStatus();
    assertTrue(status.isOK());
    assertEquals(newNews.size(), status.getItemCount());
    assertEquals(newNews.size(), status.getTotalItemCount());

    /* Simulate incoming sync (merge read state) */
    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
    assertNotNull(feed.getPublishDate());
    assertFalse(feed.getNews().isEmpty());

    /* Assert Read State */
    for (INews news : feed.getNews()) {
      if (news.getState() == INews.State.NEW)
        fail("Unexpected state");
    }

    /* Test Mark Unread */
    syncItems = new ArrayList<SyncItem>();
    for (INews news : newNews) {
      SyncItem item = SyncItem.toSyncItem(news);
      item.setMarkedUnread();
      syncItems.add(item);
    }

    service.testSync(syncItems);

    /* Assert Status */
    assertNotNull(service.getStatus());
    status = service.getStatus();
    assertTrue(status.isOK());
    assertEquals(newNews.size(), status.getItemCount());
    assertEquals(newNews.size() * 2, status.getTotalItemCount());

    /* Simulate incoming sync (merge read state) */
    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
    assertNotNull(feed.getPublishDate());
    assertFalse(feed.getNews().isEmpty());

    /* Assert Read State */
    List<INews> unreadNews = new ArrayList<INews>();
    for (INews news : feed.getNews()) {
      if (news.getState() == INews.State.UNREAD)
        unreadNews.add(news);
    }

    assertTrue(unreadNews.size() == newNews.size());

    /* Test Outgoing Sync (mark read) */
    syncItems = new ArrayList<SyncItem>();
    for (INews news : unreadNews) {
      SyncItem item = SyncItem.toSyncItem(news);
      item.setMarkedRead();
      syncItems.add(item);
    }

    service.testSync(syncItems);

    /* Assert Status */
    assertNotNull(service.getStatus());
    status = service.getStatus();
    assertTrue(status.isOK());
    assertEquals(unreadNews.size(), status.getItemCount());
    assertEquals(unreadNews.size() * 3, status.getTotalItemCount());

    /* Simulate incoming sync (merge read state) */
    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
View Full Code Here


    service.testSync(syncItems);

    /* Assert Status */
    assertNotNull(service.getStatus());
    SyncStatus status = service.getStatus();
    assertTrue(status.isOK());
    assertEquals(syncItems.size(), status.getItemCount());
    assertEquals(syncItems.size(), status.getTotalItemCount());

    /* Simulate incoming sync (merge starred state and labels) */
    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
    assertNotNull(feed.getPublishDate());
    assertFalse(feed.getNews().isEmpty());

    /* Assert Starred State and Labels */
    for (INews news : feed.getNews()) {
      if (!guids.contains(news.getGuid().getValue()))
        continue;

      assertTrue(news.isFlagged());
      Set<ILabel> labels = news.getLabels();
      assertTrue(labels.size() >= 2);
      int count = 0;
      for (ILabel label : labels) {
        if ("Testing".equals(label.getName()) && label.getId() > 0)
          count++;
        else if ("Hello World".equals(label.getName()) && label.getId() > 0)
          count++;
      }

      assertEquals(2, count);
    }

    /* Test removing starred state and labels */
    syncItems = new ArrayList<SyncItem>();
    for (INews news : newsToSync) {
      SyncItem item = SyncItem.toSyncItem(news);
      item.setUnStarred();
      item.removeLabel("Testing");
      item.removeLabel("Hello World");
      syncItems.add(item);
    }

    service.testSync(syncItems);

    /* Assert Status */
    assertNotNull(service.getStatus());
    status = service.getStatus();
    assertTrue(status.isOK());
    assertEquals(syncItems.size(), status.getItemCount());
    assertEquals(syncItems.size() * 2, status.getTotalItemCount());

    /* Simulate incoming sync (merge starred state and labels) */
    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
View Full Code Here

    item.addLabel(label.getName());

    service.testSync(Collections.singleton(item));

    assertNotNull(service.getStatus());
    SyncStatus status = service.getStatus();
    assertEquals(1, status.getItemCount());
    assertEquals(1, status.getTotalItemCount());

    Controller.getDefault().reload(bm, null, null);

    assertNotNull(feed.getTitle());
    assertNotNull(feed.getPublishDate());
View Full Code Here

    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);
    Controller.getDefault().reload(golemBm, null, null);

View Full Code Here

    item.addLabel("World Hello");

    service.testSync(Collections.singleton(item));

    assertNotNull(service.getStatus());
    SyncStatus status = service.getStatus();
    assertEquals(1, status.getItemCount());
    assertEquals(1, status.getTotalItemCount());

    Controller.getDefault().reload(bildBm, null, null);

    final AtomicBoolean listenerCalled = new AtomicBoolean();
    NewsListener listener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        listenerCalled.set(true);
      }
    };
    DynamicDAO.addEntityListener(INews.class, listener);

    try {
      Controller.getDefault().reload(bildBm, null, null);
      assertFalse(listenerCalled.get());
    } finally {
      DynamicDAO.removeEntityListener(INews.class, listener);
    }

    /* Clean Up */
    item = SyncItem.toSyncItem(bildNews);
    item.setUnStarred();
    item.removeLabel("Foo");
    item.removeLabel("Bar");
    item.removeLabel("Hello World");
    item.removeLabel("World Hello");

    service.testSync(Collections.singleton(item));

    assertNotNull(service.getStatus());
    status = service.getStatus();
    assertEquals(1, status.getItemCount());
    assertEquals(2, status.getTotalItemCount());
  }
View Full Code Here

    item.addLabel("World Hello");

    service.testSync(Collections.singleton(item));

    assertNotNull(service.getStatus());
    SyncStatus status = service.getStatus();
    assertEquals(1, status.getItemCount());
    assertEquals(1, status.getTotalItemCount());

    Controller.getDefault().reload(testBm, null, null);

    assertEquals(5, testNews.getLabels().size());
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.services.SyncService.SyncStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.