Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Bookmark


    assertEquals(2,searchResult.length());
  }
 
  public void testGetResult() throws Exception{
    searchResult = new BookmarkSearchResult(getGnizrDao(),"MySQL Boolean");
    Bookmark link1 = searchResult.getResult(0);
    assertNotNull(link1);
    assertEquals(3,link1.getId());
    Bookmark link2 = searchResult.getResult(1);
    assertNotNull(link2);
    assertNotNull(link2.getUser().getUsername());
  }
View Full Code Here


    int cnt = forUserManager.getForUserCount(new User(2));
    assertEquals(1,cnt);
    cnt = forUserManager.getForUserCount(new User(3));
    assertEquals(0,cnt);
   
    Bookmark b = new Bookmark();
    b.setTitle("example site");
    b.setLink(new Link("http://example.org/foobar"));
    b.setTags("abc 123 for:jsmith for:hchen1");
    b.setUser(new User(1));
   
    int id = bookmarkManager.addBookmark(b);
   
    Bookmark bm = bookmarkManager.getBookmark(id);
    bm.setTags(bm.getTags() + " for:hchen1 for:jsmith for:foobar for:crap");
    assertTrue(bookmarkManager.updateBookmark(bm));
    bookmarkManager.shutdown();
   
    cnt = forUserManager.getForUserCount(new User(2));
    assertEquals(2,cnt);
View Full Code Here

  public void testGetResults() throws Exception{
    searchResult = new BookmarkSearchResult(getGnizrDao(),"fulltext mysql -Boolean");
    List<Bookmark> links = searchResult.getResults(0,10);
    assertEquals(1,links.size());
   
    Bookmark link1 = links.get(0);
    assertNotNull(link1);
    assertEquals(4,link1.getId());
    assertNotNull(link1.getUser().getUsername());
   
  }
View Full Code Here

  public DaoResult<Folder> pageContainedInFolder(User user, String url, int offset, int count) throws NoSuchUserException, NoSuchLinkException, MissingIdException, NoSuchBookmarkException{
    GnizrDaoUtil.fillId(userDao, user);
    if(url == null){
      throw new NullPointerException("url is null");
   
    Bookmark bmark = new Bookmark();
    bmark.setLink(new Link(url));
    bmark.setUser(user);
    GnizrDaoUtil.fillId(bookmarkDao, userDao, linkDao, bmark);
    return folderDao.pageContainedInFolders(bmark, offset, count);
  }
View Full Code Here

    User user1 = new User(1);
    Link link1 = new Link(1);
    Link link2 = new Link(2);
    Link link3 = new Link(3);
   
    Bookmark bm1 = new Bookmark(user1,link1);
    bm1.setTags("tags1 tags2 tags3");
    bm1.setTitle("title foobar1");
   
    Bookmark bm2 = new Bookmark(user1,link2);
    bm2.setTags("tags4 tags5 tags6");
    bm2.setTitle("title foobar1");
   
    Bookmark bm3 = new Bookmark(user1,link3);
    bm3.setTags("tags1 tags");
    bm3.setTitle("title3 foobar2");
   
    assertTrue(bmManager.addBookmark(bm1)>0);
    assertTrue(bmManager.addBookmark(bm2)>0);
    assertTrue(bmManager.addBookmark(bm3)>0);
  }
View Full Code Here

        .getResourceAsStream("/TestBookmarkManager-input.xml"));
  }

  public void testAddBookmark() throws Exception {
    User gUser = new User("hchen1");
    Bookmark gBookmark = new Bookmark();
    gBookmark.setUser(gUser);
    gBookmark.setLink(new Link("http://www.umbc.edu"));
    gBookmark.setTitle("UMBC");
    gBookmark.setNotes("UMBC homepage");   
    int id = manager.addBookmark(gBookmark);
    assertTrue(id > 0);
    BookmarkDao bookmarkDao = getGnizrDao().getBookmarkDao();   
   
    GnizrDaoUtil.fillObject(bookmarkDao,userDao,linkDao,gBookmark);
View Full Code Here

  }
   
  public void testDeleteBookmark() throws Exception{
    User user = new User(2);
    Link link = new Link(204);
    Bookmark bookmark = new Bookmark(user,link);
    bookmark.setTitle("webwork learning");
    bookmark.setTags("webwork programming learning");
    assertTrue((manager.addBookmark(bookmark)>0));
   
    bookmark = bookmarkDao.findBookmark(user, link).get(0);
    assertNotNull(bookmark);
   
View Full Code Here

    assertEquals((0),lt.getTag().getCount());   
  }
 
 
  public void testUpdateBookmark() throws Exception{
    Bookmark bm = bookmarkDao.getBookmark(300);
    assertEquals(202,bm.getLink().getId());
   
    // change the link that this bookmark ref
    Link link = new Link(204);
    bm.setLink(link);
   
    // change tag counts
    bm.setTags("foobar");
   
    // change the URL link that this bookmark reference
    Link ln = new Link("http://newlink.com");
    bm.setLink(ln);
   
    assertTrue(manager.updateBookmark(bm));
   
    bm = bookmarkDao.getBookmark(300);
    GnizrDaoUtil.fillObject(bookmarkDao, userDao, linkDao, bm);
    assertEquals("foobar",bm.getTags());
    Tag cnn = tagDao.findTag("cnn").get(0);
    assertEquals(0,cnn.getCount());
    Tag news = tagDao.findTag("news").get(0);
    assertEquals(0,news.getCount());
    Tag foobar = tagDao.findTag("foobar").get(0);
    assertEquals(1,foobar.getCount());
    UserTag foobar_u = tagDao.findUserTag(new User(1), foobar).get(0);
    assertEquals(1,foobar_u.getCount());
   
    Link bmLink = bm.getLink();
    assertEquals(ln.getUrl(),bmLink.getUrl());
    assertEquals(Link.computeUrlHash(ln.getUrl()),bmLink.getUrlHash());
   
    // change bookmark's notes
    bm.setNotes("hello world");
    // erase the id of the link id. make sure
    // BookmarkManager knows how to work out id from
    // the URL of the link.
    bm.getLink().setId(-1);
    assertTrue(manager.updateBookmark(bm));
    bm = bookmarkDao.getBookmark(300);
    GnizrDaoUtil.fillObject(bookmarkDao, userDao, linkDao, bm);
    assertEquals("hello world",bm.getNotes());
    assertEquals(ln.getUrl(),bm.getLink().getUrl());
    assertEquals(Link.computeUrlHash(ln.getUrl()),bm.getLink().getUrlHash());
    assertTrue((bm.getLink().getId() > 0));
  }
View Full Code Here

  private Bookmark bmark1;
 
  @Override
  protected void setUp() throws Exception {   
    super.setUp();
    bmark1 = new Bookmark(101);
    bmark1.setUser(new User("jsmith"));
    bmark1.setTitle("Title of a Bookmark");
    Link ln = new Link("http://example.org/foo1.html");
    ln.setUrlHash("123456789abcdefg");
    bmark1.setLink(ln);
View Full Code Here

   * Tests the count of indivdiual user tags are properly updated
   * after each update bookmark transaction.
   * @throws Exception
   */
  public void testUpdateBookmark2() throws Exception{
    Bookmark bm = manager.getBookmark(300);
    bm.setTags("news foobar abdc");
    assertTrue(manager.updateBookmark(bm));
   
    UserTag ut = tagDao.findUserTag(bm.getUser(),new Tag(5)).get(0);
    assertEquals(1,ut.getCount());
   
    Tag foobar = tagDao.findTag("foobar").get(0);
    assertEquals(1,foobar.getCount());
    Tag abdc = tagDao.findTag("abdc").get(0);
    assertEquals(1,abdc.getCount());
   
    Tag cnn = tagDao.findTag("cnn").get(0);
    assertEquals(0,cnn.getCount());
   
    UserTag userCnn = tagDao.findUserTag(bm.getUser(),cnn).get(0);
    assertEquals(0,userCnn.getCount());
   
    UserTag userFoobar = tagDao.findUserTag(bm.getUser(),foobar).get(0);
    assertEquals(1,userFoobar.getCount());
   
    bm.setTags("");
    assertTrue(manager.updateBookmark(bm));
   
    ut = tagDao.findUserTag(bm.getUser(),new Tag(5)).get(0);
    assertEquals(0,ut.getCount());
  }
View Full Code Here

TOP

Related Classes of com.gnizr.db.dao.Bookmark

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.