Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.Feed


   *
   * @throws Exception
   */
  @Test
  public void testSaveNewsSetsCurrentAndOldState() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news = fFactory.createNews(null, feed, new Date());
    news.setTitle("News Title #1");
    news.setLink(new URI("http://www.link.com"));
    news.setState(INews.State.UNREAD);

    final ICategory category = fFactory.createCategory(null, news);
    category.setName("Category name");

    final IAttachment attachment = fFactory.createAttachment(null, news);
    attachment.setLink(new URI("http://attachment.com"));

    feed = DynamicDAO.save(feed);

    final INews savedNews = feed.getNews().get(0);
    savedNews.setTitle("News Title Updated #1");

    Collection<INews> newsList = new ArrayList<INews>();
    newsList.add(savedNews);

View Full Code Here


   * @throws Exception
   */
  @Test
  public void testLoadFeedReference() throws Exception {
    URI feed1Url = new URI("http://www.feed1.com");
    IFeed feed1 = new Feed(feed1Url);
    feed1 = DynamicDAO.save(feed1);

    URI feed2Url = new URI("http://www.feed2.com");
    IFeed feed2 = new Feed(feed2Url);
    feed2 = DynamicDAO.save(feed2);

    assertEquals(feed1.getId().longValue(), Owl.getPersistenceService().getDAOService().getFeedDAO().loadReference(feed1Url).getId());

    assertEquals(feed2.getId().longValue(), Owl.getPersistenceService().getDAOService().getFeedDAO().loadReference(feed2Url).getId());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testLoadFeed() throws Exception {
    URI feed1Url = new URI("http://www.feed1.com");
    IFeed feed1 = new Feed(feed1Url);
    feed1 = DynamicDAO.save(feed1);

    URI feed2Url = new URI("http://www.feed2.com");
    IFeed feed2 = new Feed(feed2Url);
    feed2 = DynamicDAO.save(feed2);

    assertEquals(feed1, Owl.getPersistenceService().getDAOService().getFeedDAO().load(feed1Url));
    assertEquals(feed2, Owl.getPersistenceService().getDAOService().getFeedDAO().load(feed2Url));
  }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testSaveNews() throws Exception {
    IFeed feed1 = new Feed(new URI("http://www.feed1.com"));
    INews news11 = fFactory.createNews(null, feed1, new Date());
    news11.setLink(new URI("http://www.link11.com"));
    INews news12 = fFactory.createNews(null, feed1, new Date());
    news12.setLink(new URI("http://www.link12.com"));
    feed1 = DynamicDAO.save(feed1);

    IFeed feed2 = new Feed(new URI("http://www.feed2.com"));
    INews news21 = fFactory.createNews(null, feed2, new Date());
    news21.setLink(new URI("http://www.link21.com"));
    INews news22 = fFactory.createNews(null, feed2, new Date());
    news22.setLink(new URI("http://www.link22.com"));
    feed2 = DynamicDAO.save(feed2);

    final List<INews> newsList = new ArrayList<INews>();

    for (INews news : feed1.getNews())
      newsList.add(news);

    for (INews news : feed2.getNews())
      newsList.add(news);

    for (INews news : newsList) {
      news.setComments("updated comments");
    }
View Full Code Here

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

      Feed savedFeed = (Feed) DynamicDAO.save(feed);
      assertTrue(savedFeed.isIdentical(DynamicDAO.load(IFeed.class, savedFeed.getId())));

      NewsReference news1 = new NewsReference(savedFeed.getNews().get(0).getId());
      NewsReference news2 = new NewsReference(savedFeed.getNews().get(1).getId());
      NewsReference news3 = new NewsReference(savedFeed.getNews().get(2).getId());

      List<INews> news = new ArrayList<INews>();
      news.add(news1.resolve());
      news.add(news2.resolve());
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testSaveFeedSetsCurrentAndOldStateInNews() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news = fFactory.createNews(null, feed, new Date());
    news.setTitle("News Title #1");
    news.setLink(new URI("http://www.link.com"));
    news.setState(INews.State.UNREAD);

    feed = DynamicDAO.save(feed);

    final INews savedNews = feed.getNews().get(0);
    savedNews.setTitle("News Title Updated #1");

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equals(savedNews));
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    try {
      feed = DynamicDAO.save(feed);
    } finally {
      DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNews.getId(), event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UPDATED, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    feed.getNews().get(0).setState(State.UPDATED);
    try {
      feed = DynamicDAO.save(feed);
    } finally {
      DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testReloadFeed() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);
    Controller.getDefault().reload(createBookMark(feed), null, new NullProgressMonitor());

    assertEquals(new FeedReference(feed.getId()).resolve().getFormat(), "RSS 2.0"); //$NON-NLS-1$
  }
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testReloadBookMark() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml"));
    feed = DynamicDAO.save(feed);

    IFolder folder = Owl.getModelFactory().createFolder(null, null, "Folder");
    folder = DynamicDAO.save(folder);
    IBookMark bookmark = Owl.getModelFactory().createBookMark(1L, folder, new FeedLinkReference(feed.getLink()), "BookMark");

    Controller.getDefault().reload(bookmark, null, new NullProgressMonitor());

    assertEquals(new FeedReference(feed.getId()).resolve().getFormat(), "RSS 2.0"); //$NON-NLS-1$
  }
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testReloadBookMarkWithError() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/not_existing.xml"));
    feed = DynamicDAO.save(feed);

    IFolder folder = Owl.getModelFactory().createFolder(null, null, "Folder");
    folder = DynamicDAO.save(folder);
    IBookMark bookmark = Owl.getModelFactory().createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");

    Controller.getDefault().reload(bookmark, null, new NullProgressMonitor());

    assertEquals(true, new BookMarkReference(bookmark.getId()).resolve().isErrorLoading());
  }
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithReloadBookMark() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml"));
    feed = DynamicDAO.save(feed);

    IFolder folder = Owl.getModelFactory().createFolder(null, null, "Folder");
    folder = DynamicDAO.save(folder);
    IBookMark bookmark = Owl.getModelFactory().createBookMark(1L, folder, new FeedLinkReference(feed.getLink()), "BookMark");

    Controller.getDefault().reload(bookmark, null, new NullProgressMonitor());

    feed.getNews().get(0).setFlagged(true);
    DynamicDAO.save(feed);

    int unreadCounter = getUnreadCount(feed);
    int newCounter = getNewCount(feed);
    int stickyCounter = getStickyCount(feed);
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.Feed

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.