Package org.rssowl.core.model.reference

Examples of org.rssowl.core.model.reference.NewsReference


    fModel.getTypesFactory().createNews(null, feed, new Date());
    fModel.getTypesFactory().createNews(null, feed, new Date());

    FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

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

    List<NewsReference> news = new ArrayList<NewsReference>();
    news.add(news1);
    news.add(news2);

    assertEquals(news1.resolve().getState(), INews.State.NEW);
    assertEquals(news2.resolve().getState(), INews.State.NEW);
    assertEquals(news3.resolve().getState(), INews.State.NEW);

    for (NewsReference reference : news) {
      INews newsitem = reference.resolve();
      newsitem.setState(INews.State.UNREAD);
      fDao.saveNews(newsitem);
    }

    assertEquals(news1.resolve().getState(), INews.State.UNREAD);
    assertEquals(news2.resolve().getState(), INews.State.UNREAD);
    assertEquals(news3.resolve().getState(), INews.State.NEW);

    for (NewsReference reference : news) {
      INews newsitem = reference.resolve();
      newsitem.setState(INews.State.READ);
      fDao.saveNews(newsitem);
    }

    assertEquals(news1.resolve().getState(), INews.State.READ);
    assertEquals(news2.resolve().getState(), INews.State.READ);
    assertEquals(news3.resolve().getState(), INews.State.NEW);

    for (NewsReference reference : news) {
      INews newsitem = reference.resolve();
      newsitem.setState(INews.State.DELETED);
      fDao.saveNews(newsitem);
    }

    assertEquals(news1.resolve().getState(), INews.State.DELETED);
    assertEquals(news2.resolve().getState(), INews.State.DELETED);
    assertEquals(news3.resolve().getState(), INews.State.NEW);
  }
View Full Code Here


      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFolder(new FolderReference(root.getId()));

      assertNull("Expected this Entity to be NULL", new FolderReference(root.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = fDao.saveFolder(folder);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed2.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, feed.getLink(),
          feedRef, "BookMark");
      folder = fDao.saveFolder(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFolder(new FolderReference(folder.getId()));

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted #2) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = fDao.saveFolder(folder);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed3.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, feed.getLink(),
          feedRef, "BookMark");
      folder = fDao.saveFolder(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      /* Delete by calling delete */
      fDao.deleteFolder(new FolderReference(folder.getId()));

      final long rootFolderId = root.getId();
      FolderListener folderListener = new FolderAdapter() {
        @Override
        public void folderUpdated(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            if (event.getEntity().getId() == rootFolderId)
              assertTrue(event.isRoot());
            else
              assertFalse(event.isRoot());
          }
        }
      };
      NewsModel.getDefault().addFolderListener(folderListener);
      try {
        fDao.saveFolder(root);
      } finally {
        NewsModel.getDefault().removeFolderListener(folderListener);
      }

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Folder, BookMark, Feed, News (BookMark Deleted) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed4.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, root, feed.getLink(), feedRef, "BookMark");
      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteBookMark(new BookMarkReference(mark.getId()));

      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Folder, BookMark, Feed, News (BookMark Deleted #2) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed5.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, root, feed.getLink(), feedRef, "BookMark");
      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      /* Delete by calling delete */
      fDao.deleteBookMark(new BookMarkReference(mark.getId()));

      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Feed, News (Feed Deleted) */
    {
      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed6.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFeed(feedRef);

      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }
  }
View Full Code Here

      fModel.getTypesFactory().createNews(null, feed, new Date());

      Feed savedFeed = (Feed) fDao.saveFeed(feed);
      assertTrue(savedFeed.isIdentical(fDao.loadFeed(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());

      assertEquals(news1.resolve().getState(), INews.State.NEW);
      assertEquals(news2.resolve().getState(), INews.State.NEW);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      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());
        }
      };
      fModel.addNewsListener(newsListener);

      fModel.getPersistenceLayer().getApplicationLayer().setNewsState(news, INews.State.UNREAD, true, false);

      assertEquals(news1.resolve().getState(), INews.State.UNREAD);
      assertEquals(news2.resolve().getState(), INews.State.UNREAD);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      fModel.getPersistenceLayer().getApplicationLayer().setNewsState(news, INews.State.READ, true, false);

      assertEquals(news1.resolve().getState(), INews.State.READ);
      assertEquals(news2.resolve().getState(), INews.State.READ);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      fModel.getPersistenceLayer().getApplicationLayer().setNewsState(news, INews.State.DELETED, true, false);

      assertEquals(news1.resolve().getState(), INews.State.DELETED);
      assertEquals(news2.resolve().getState(), INews.State.DELETED);
      assertEquals(news3.resolve().getState(), INews.State.NEW);
    } catch (PersistenceException e) {
      TestUtils.fail(e);
    } finally {
      if (newsListener != null)
        fModel.removeNewsListener(newsListener);
View Full Code Here

          }
        }
      };
      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()));
View Full Code Here

    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

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

    NewsModel.getDefault().getPersistenceLayer().getModelDAO().deleteNews(new NewsReference(feed.getNews().get(0).getId()));

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

    assertEquals(INews.State.UPDATED, feed.getNews().get(0).getState());

    feed.getNews().get(0).setState(INews.State.READ);
    feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);

    NewsModel.getDefault().getPersistenceLayer().getModelDAO().deleteNews(new NewsReference(feed.getNews().get(0).getId()));

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

     
      news.setState(State.NEW);
      fModelDAO.saveNews(news);
     
      NewsModel.getDefault().removeNewsListener(newsListener);
      fModelDAO.deleteNews(new NewsReference(news.getId()));
      fModelDAO.deleteFeed(new FeedReference(feed.getId()));
    } finally {
      if (newsListener != null) {
        NewsModel.getDefault().removeNewsListener(newsListener);
      }
View Full Code Here

    IFeed feed = createFeed();
    feed = fModelDAO.saveFeed(feed);
    INews news = createNews(feed);
    news = fModelDAO.saveNews(news);
    Long newsId = news.getId();
    fModelDAO.deleteNews(new NewsReference(newsId));
    feed = fModelDAO.loadFeed(feed.getId());
    assertEquals(0, feed.getNews().size());
    assertNull(fModelDAO.loadNews(newsId));
  }
View Full Code Here

      };
      NewsModel.getDefault().addNewsListener(newsListener);
      fModelDAO.saveNews(initialNews);
      assertTrue(NewsAddedCalled[0]);
      assertTrue(NewsUpdatedCalled[0]);
      fModelDAO.deleteNews(new NewsReference(updatedNews[0].getId()));
    } catch (PersistenceException e) {
      fail(e.getMessage());
    } finally {
      if (newsListener != null) {
        NewsModel.getDefault().removeNewsListener(newsListener);
View Full Code Here

      NewsModel.getDefault().addNewsListener(newsListener);
      List<INews> newsList = new ArrayList<INews>();
      newsList.add(news);
      fAppLayer.setNewsState(newsList, State.NEW, true, false);
      NewsModel.getDefault().removeNewsListener(newsListener);
      fModelDAO.deleteNews(new NewsReference(news.getId()));
      fModelDAO.deleteFeed(new FeedReference(feed.getId()));
    } catch (PersistenceException e) {
      fail(e.getMessage());
    } finally {
      if (newsListener != null) {
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.reference.NewsReference

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.