Package org.rssowl.core.model.reference

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


    IBookMark bookmark2 = fFactory.createBookMark(null, root1Ref.resolve(),
        feed.getLink(), feedRef, "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1Ref.resolve(),
        feed.getLink(), feedRef, "Bookmark 3");

    BookMarkReference bookmarkRef1 = new BookMarkReference(fDao.saveBookMark(bookmark1).getId());
    BookMarkReference bookmarkRef2 = new BookMarkReference(fDao.saveBookMark(bookmark2).getId());
    BookMarkReference bookmarkRef3 = new BookMarkReference(fDao.saveBookMark(bookmark3).getId());

    List<IBookMark> filledBookmarks = fAppLayer.loadBookMarks(feedRef.resolve());
    assertEquals(3, filledBookmarks.size());
    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
      else if (bookmarkRef2.resolve().equals(mark))
        assertEquals(bookmark2.getName(), mark.getName());
      else if (bookmarkRef3.resolve().equals(mark))
        assertEquals(bookmark3.getName(), mark.getName());
      else
        fail();
    }
  }
View Full Code Here


    IBookMark bookmark2 = fFactory.createBookMark(null, root1, feed.getLink(),
        feedRef, "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1, feed.getLink(),
        feedRef, "Bookmark 3");

    BookMarkReference bookmarkRef1 = new BookMarkReference(fDao.saveBookMark(bookmark1).getId());
    BookMarkReference bookmarkRef2 = new BookMarkReference(fDao.saveBookMark(bookmark2).getId());
    BookMarkReference bookmarkRef3 = new BookMarkReference(fDao.saveBookMark(bookmark3).getId());

    List<IBookMark> filledBookmarks = fAppLayer.loadAllBookMarks(true);
    assertEquals(3, filledBookmarks.size());

    filledBookmarks = fAppLayer.loadAllBookMarks(false);
    assertEquals(3, filledBookmarks.size());

    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
      else if (bookmarkRef2.resolve().equals(mark))
        assertEquals(bookmark2.getName(), mark.getName());
      else if (bookmarkRef3.resolve().equals(mark))
        assertEquals(bookmark3.getName(), mark.getName());
      else
        fail();
    }
  }
View Full Code Here

  @Test
  public void testAddAndDeleteBookMark() {
    try {
      IBookMark bookMark = createBookMark();
      bookMark = fModelDAO.saveBookMark(bookMark);
      fModelDAO.deleteBookMark(new BookMarkReference(bookMark.getId()));
    } catch (PersistenceException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    feed = fDao.saveFeed(feed);
    fFactory.createBookMark(null, folder, feed.getLink(),
        new FeedReference(feed.getId()), "Mark");
    IFolder savedFolder = fDao.saveFolder(folder);
    IBookMark savedMark = (IBookMark) savedFolder.getMarks().get(0);
    fDao.deleteBookMark(new BookMarkReference(savedMark.getId()));
    assertNotNull(fDao.loadFolder(savedFolder.getId()));
  }
View Full Code Here

      fFactory.createBookMark(null, folder, feed.getLink(),
          new FeedReference(feed.getId()), "Mark");
      IFolder savedFolder = fDao.saveFolder(folder);
      IBookMark savedMark = (IBookMark) savedFolder.getMarks().get(0);
      IFeed savedFeed = savedMark.getFeedReference().resolve();
      fDao.deleteBookMark(new BookMarkReference(savedMark.getId()));
      assertNull("Feed must also be deleted since no more bookmarks reference it", fDao.loadFeed(savedFeed.getId()));
    }
    {
      IFolder folder = fFactory.createFolder(null, null, "AnotherFolder");
      IFeed feed = createFeed("http://www.anotherurl.com");
      feed = fDao.saveFeed(feed);
      fFactory.createBookMark(null, folder, feed.getLink(),
          new FeedReference(feed.getId()), "Mark1");
      fFactory.createBookMark(null, folder, feed.getLink(),
          new FeedReference(feed.getId()), "Mark2");
      IFolder savedFolder = fDao.saveFolder(folder);
      IBookMark savedMark1 = (IBookMark) savedFolder.getMarks().get(0);
      IBookMark savedMark2 = (IBookMark) savedFolder.getMarks().get(1);
      if (savedMark1.getName().equals("Mark2")) {
        IBookMark tempMark = savedMark1;
        savedMark1 = savedMark2;
        savedMark2 = tempMark;
      }
      IFeed savedFeed = savedMark1.getFeedReference().resolve();
      fDao.deleteBookMark(new BookMarkReference(savedMark1.getId()));
      assertNotNull("Feed must not be deleted since one bookmark references it", fDao.loadFeed(savedFeed.getId()));
      fDao.deleteBookMark(new BookMarkReference(savedMark2.getId()));
      assertNull("Feed must also be deleted since no more bookmarks reference it", fDao.loadFeed(savedFeed.getId()));
    }
  }
View Full Code Here

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

      IBookMark bookMark1 = fFactory.createBookMark(null, rootRef.resolve(),
          feed.getLink(), feedRef, "Root BookMark");
      root = fDao.saveFolder(bookMark1.getFolder());
      final BookMarkReference bookMarkRef1 = new BookMarkReference(root.getMarks().get(0).getId());

      IBookMark bookMark2 = fFactory.createBookMark(null, rootChildRef.resolve(),
          feed.getLink(), feedRef, "Root Child BookMark");
      rootChild = fDao.saveFolder(bookMark2.getFolder());
      final BookMarkReference bookMarkRef2 = new BookMarkReference(rootChild.getMarks().get(0).getId());

      IBookMark bookMark3 = fFactory.createBookMark(null, rootChildChild1Ref.resolve(),
          feed.getLink(), feedRef, "Root Child Child #1 BookMark");
      rootChildChild1 = fDao.saveFolder(bookMark3.getFolder());
      final BookMarkReference bookMarkRef3 = new BookMarkReference(rootChildChild1.getMarks().get(0).getId());

      final boolean bookMarkEventsIssued[] = new boolean[3];
      final boolean feedEventsIssued[] = new boolean[1];

      bookMarkListener = new BookMarkAdapter() {
        @Override
        public void bookMarkDeleted(Set<BookMarkEvent> events) {
          for (BookMarkEvent event : events) {
            IBookMark bookMark = event.getEntity();

            if (bookMarkRef1.references(bookMark))
              bookMarkEventsIssued[0] = true;

            else if (bookMarkRef2.references(bookMark))
              bookMarkEventsIssued[1] = true;

            else if (bookMarkRef3.references(bookMark))
              bookMarkEventsIssued[2] = true;
          }
        }
      };
      fModel.addBookMarkListener(bookMarkListener);
View Full Code Here

      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());
      final FolderReference folderRef = new FolderReference(fDao.saveFolder(fFactory.createFolder(null, null, "Folder")).getId());
      IBookMark bookMark = fFactory.createBookMark(null, folderRef.resolve(),
          feed.getLink(), feedRef, "BookMark");
      final boolean bookMarkEvents[] = new boolean[3];
      final BookMarkReference bookMarkReference[] = new BookMarkReference[1];
      bookMarkListener = new BookMarkListener() {
        public void bookMarkAdded(Set<BookMarkEvent> events) {
          for (BookMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
            bookMarkEvents[0] = true;
          }
        }

        public void bookMarkDeleted(Set<BookMarkEvent> events) {
          for (BookMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
            if (bookMarkReference[0].references(event.getEntity()))
              bookMarkEvents[1] = true;
          }
        }

        public void bookMarkUpdated(Set<BookMarkEvent> events) {
          for (BookMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
            if (bookMarkReference[0].references(event.getEntity()))
              bookMarkEvents[2] = true;
          }
        }
      };
      fModel.addBookMarkListener(bookMarkListener);
      bookMarkReference[0] = new BookMarkReference(fDao.saveBookMark(bookMark).getId());

      /* Update */
      bookMark = bookMarkReference[0].resolve();
      bookMark.setName("BookMark Updated");
      fDao.saveBookMark(bookMark);
View Full Code Here

      bookMark.setProperty("String", "Foo");
      bookMark.setProperty("Integer", 1);
      bookMark.setProperty("Boolean", true);
      bookMark.setProperty("Double", 2.2D);
      bookMark.setProperty("Float", 3.3F);
      BookMarkReference bookMarkRef = new BookMarkReference(fDao.saveBookMark(bookMark).getId());
      bookMark = bookMarkRef.resolve();
      assertEquals("Foo", bookMark.getProperty("String"));
      assertEquals(1, bookMark.getProperty("Integer"));
      assertEquals(true, bookMark.getProperty("Boolean"));
      assertEquals(2.2D, bookMark.getProperty("Double"));
      assertEquals(3.3F, bookMark.getProperty("Float"));
View Full Code Here

      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) */
 
View Full Code Here

        }
      }
    }

    else if (entity instanceof IBookMark) {
      IBookMark bookmark = new BookMarkReference(entity.getId()).resolve();
      count += bookmark.getFeedReference().resolve().getVisibleNews().size();
    }

    else if (entity instanceof IFeed) {
      count += ((IFeed) entity).getVisibleNews().size();
View Full Code Here

TOP

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

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.