Package org.rssowl.ui.internal

Examples of org.rssowl.ui.internal.NewsService


   */
  @Test
  public void testSetNewsStateOnPlanet() throws Exception {
    NewsListener newsListener = null;
    try {
      NewsService service = Controller.getDefault().getNewsService();

      IFeed feed1 = fFactory.createFeed(null, new URI("http://www.feed.com"));
      IFeed feed2 = fFactory.createFeed(null, new URI("http://www.feed2.com"));

      INews news1 = fFactory.createNews(null, feed1, new Date());
      news1.setLink(new URI("www.link.com"));

      INews news2 = fFactory.createNews(null, feed2, new Date());
      news2.setLink(new URI("www.link.com"));

      fFactory.createNews(null, feed1, new Date());
      fFactory.createNews(null, feed2, new Date());

      feed1 = DynamicDAO.save(feed1);
      feed2 = DynamicDAO.save(feed2);

      assertEquals(2, service.getUnreadCount(news1.getFeedReference()));
      assertEquals(2, service.getNewCount(news1.getFeedReference()));
      assertEquals(2, service.getUnreadCount(news2.getFeedReference()));
      assertEquals(2, service.getNewCount(news2.getFeedReference()));

      final long feed1ID = feed1.getId();
      final long feed2ID = feed2.getId();
      final long news1ID = feed1.getNews().get(0).getId();
      final long news2ID = feed2.getNews().get(0).getId();

      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          fail("Unexpected Event!");
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Unexpected Event!");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(2, events.size());
          for (NewsEvent event : events) {
            INews news = event.getEntity();
            IFeed parent = news.getFeedReference().resolve();

            if (news.getId() == news1ID)
              assertEquals(feed1ID, parent.getId());
            else if (news.getId() == news2ID)
              assertEquals(feed2ID, parent.getId());
            else
              fail("Unexpected Reference in Event!");
          }
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      Owl.getPersistenceService().getDAOService().getNewsDAO().setState(Arrays.asList(new INews[] { new NewsReference(news1ID).resolve() }), INews.State.READ, true, false);

      assertEquals(1, service.getUnreadCount(news1.getFeedReference()));
      assertEquals(1, service.getNewCount(news1.getFeedReference()));
      assertEquals(1, service.getUnreadCount(news2.getFeedReference()));
      assertEquals(1, service.getNewCount(news2.getFeedReference()));
    } finally {
      if (newsListener != null)
        DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
  }
View Full Code Here


   */
  @Test
  public void testSetNewsStateOnPlanet() throws Exception {
    NewsListener newsListener = null;
    try {
      NewsService service = Controller.getDefault().getNewsService();

      IFeed feed1 = fModel.getTypesFactory().createFeed(null, new URL("http://www.feed.com"));
      IFeed feed2 = fModel.getTypesFactory().createFeed(null, new URL("http://www.feed2.com"));

      INews news1 = fModel.getTypesFactory().createNews(null, feed1, new Date());
      news1.setLink(new URI("www.link.com"));

      INews news2 = fModel.getTypesFactory().createNews(null, feed2, new Date());
      news2.setLink(new URI("www.link.com"));

      fModel.getTypesFactory().createNews(null, feed1, new Date());
      fModel.getTypesFactory().createNews(null, feed2, new Date());

      feed1 = fDao.saveFeed(feed1);
      feed2 = fDao.saveFeed(feed2);

      assertEquals(2, service.getUnreadCount(news1.getFeedReference()));
      assertEquals(2, service.getNewCount(news1.getFeedReference()));
      assertEquals(2, service.getUnreadCount(news2.getFeedReference()));
      assertEquals(2, service.getNewCount(news2.getFeedReference()));

      final long feed1ID = feed1.getId();
      final long feed2ID = feed2.getId();
      final long news1ID = feed1.getNews().get(0).getId();
      final long news2ID = feed2.getNews().get(0).getId();

      newsListener = new NewsListener() {
        public void newsAdded(Set<NewsEvent> events) {
          fail("Unexpected Event!");
        }

        public void newsDeleted(Set<NewsEvent> events) {
          fail("Unexpected Event!");
        }

        public void newsUpdated(Set<NewsEvent> events) {
          assertEquals(2, events.size());
          for (NewsEvent event : events) {
            INews news = event.getEntity();
            IFeed parent = news.getFeedReference().resolve();

            if (news.getId() == news1ID)
              assertEquals(feed1ID, parent.getId());
            else if (news.getId() == news2ID)
              assertEquals(feed2ID, parent.getId());
            else
              fail("Unexpected Reference in Event!");
          }
        }
      };
      fModel.addNewsListener(newsListener);

      fAppLayer.setNewsState(Arrays.asList(new INews[] { new NewsReference(news1ID).resolve() }), INews.State.READ, true, false);

      assertEquals(1, service.getUnreadCount(news1.getFeedReference()));
      assertEquals(1, service.getNewCount(news1.getFeedReference()));
      assertEquals(1, service.getUnreadCount(news2.getFeedReference()));
      assertEquals(1, service.getNewCount(news2.getFeedReference()));
    } finally {
      if (newsListener != null)
        fModel.removeNewsListener(newsListener);
    }
  }
View Full Code Here

    NewsModel.getDefault().getPersistenceLayer().getModelSearch().stopIndexer();
    NewsModel.getDefault().getPersistenceLayer().recreateSchema();
  }
 
  private int getNewCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }
 
  private int getUnreadCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getUnreadCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testNewsService() throws Exception {
    NewsService service = Controller.getDefault().getNewsService();

    IFeed feed = new Feed(new URL("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml")); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getTypesFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(1, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.READ, true, false);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.UNREAD, true, false);
    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.READ, true, false);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.UPDATED, true, false);
    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.READ, true, false);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    /* Simulate Shutdown */
    service.stopService();

    NewsModel.getDefault().getTypesFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    NewsModel.getDefault().getTypesFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    assertEquals(2, getUnreadCount(feed));
    assertEquals(2, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.READ, true, false);

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    NewsModel.getDefault().getPersistenceLayer().getApplicationLayer().setNewsState(feed.getNews(), INews.State.UNREAD, true, false);

    assertEquals(3, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    /* Simulate Dirty Shutdown */
    NewsModel.getDefault().getPersistenceLayer().recreateSchema();

    feed = new Feed(new URL("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml")); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    NewsModel.getDefault().getTypesFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    NewsModel.getDefault().getTypesFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    service.testDirtyShutdown();

    assertEquals(2, getUnreadCount(feed));
    assertEquals(2, getNewCount(feed));
  }
View Full Code Here

    assertEquals(true, new BookMarkReference(bookmark.getId()).resolve().isErrorLoading());
  }

  private int getNewCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }

  private int getUnreadCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getUnreadCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

    NewsService service = Controller.getDefault().getNewsService();
    return service.getUnreadCount(new FeedLinkReference(feed.getLink()));
  }

  private int getStickyCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getStickyCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

    Owl.getPersistenceService().getModelSearch().shutdown();
    Controller.getDefault().getNewsService().testDirtyShutdown();
  }

  private int getNewCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

    NewsService service = Controller.getDefault().getNewsService();
    return service.getNewCount(new FeedLinkReference(feed.getLink()));
  }

  private int getUnreadCount(IFeed feed) {
    NewsService service = Controller.getDefault().getNewsService();
    return service.getUnreadCount(new FeedLinkReference(feed.getLink()));
  }
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.NewsService

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.