Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Folder


    List<Bookmark> bmarks = null;
    Date d1 = null;
    Date d2 = null;
    Date d3 = null;

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_CREATED_ON, FolderDao.ASCENDING);
    bmarks = result.getResult();
    d1 = bmarks.get(0).getCreatedOn();
    d2 = bmarks.get(1).getCreatedOn();
    d3 = bmarks.get(2).getCreatedOn();
    assertTrue(d1.before(d2));
    assertTrue(d2.before(d3));

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_CREATED_ON, FolderDao.DESCENDING);
    bmarks = result.getResult();
    d1 = bmarks.get(0).getCreatedOn();
    d2 = bmarks.get(1).getCreatedOn();
    d3 = bmarks.get(2).getCreatedOn();
View Full Code Here


    List<Bookmark> bmarks = null;
    Date d1 = null;
    Date d2 = null;
    Date d3 = null;

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_LAST_UPDATED, FolderDao.DESCENDING);
    bmarks = result.getResult();
    d1 = bmarks.get(0).getLastUpdated();
    d2 = bmarks.get(1).getLastUpdated();
    d3 = bmarks.get(2).getLastUpdated();
    assertTrue(d1.after(d2));
    assertTrue(d2.after(d3));

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_LAST_UPDATED, FolderDao.ASCENDING);
    bmarks = result.getResult();
    d1 = bmarks.get(0).getLastUpdated();
    d2 = bmarks.get(1).getLastUpdated();
    d3 = bmarks.get(2).getLastUpdated();
View Full Code Here

  public void testPageBookmarks4() throws Exception {
    DaoResult<Bookmark> result = null;
    List<Bookmark> bmarks = null;

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_FLDR_LAST_UPDATED, FolderDao.DESCENDING);
    bmarks = result.getResult();
    assertEquals(303, bmarks.get(0).getId());
    assertEquals(301, bmarks.get(1).getId());
    assertEquals(300, bmarks.get(2).getId());

    result = folderDao.pageBookmarks(new Folder(1), 0, 3,
        FolderDao.SORT_BY_BMRK_FLDR_LAST_UPDATED, FolderDao.ASCENDING);
    bmarks = result.getResult();
    assertEquals(300, bmarks.get(0).getId());
    assertEquals(301, bmarks.get(1).getId());
    assertEquals(303, bmarks.get(2).getId());
View Full Code Here

  }

  public void testAddBookmarksToFolder() throws Exception {
    Date now = GregorianCalendar.getInstance().getTime();

    Folder folderX = new Folder();
    folderX.setName("projectX");
    folderX.setUser(new User(1));
    folderX.setDescription("");
    folderX.setLastUpdated(now);

    int fid = folderDao.createFolder(folderX);
    assertTrue((fid > 0));
    folderX.setId(fid);

    List<Bookmark> bmark2add = new ArrayList<Bookmark>();
    bmark2add.add(new Bookmark(300));
    bmark2add.add(new Bookmark(301));
    bmark2add.add(new Bookmark(302));

    boolean[] opOkay = folderDao.addBookmarks(folderX, bmark2add, now);
    for(boolean b: opOkay){
      assertTrue(b);
    }

    folderX = folderDao.getFolder(fid);
    assertEquals(3, folderX.getSize());

    DaoResult<Bookmark> bmarks = folderDao.pageBookmarks(folderX, 0, 1);
    assertEquals(3, bmarks.getSize());
    assertEquals(1, bmarks.getResult().size());
    assertNotNull(bmarks.getResult().get(0).getUser());
View Full Code Here

  protected IDataSet getDataSet() throws Exception {
    return new FlatXmlDataSet(TestTagDBDao1.class.getResourceAsStream("/dbunit/tagdbdao/TestTagDBDao3-input.xml"));
  }
 
  public void testAddTagCountOne() throws Exception{
    List<FolderTag> folderTags = folderDao.findTagsInFolder(new Folder(2), 0, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
    FolderTag t1 = folderTags.get(0);
    FolderTag t2 = folderTags.get(1);
   
    assertEquals("cnn",t1.getTag().getLabel());
    assertEquals("news",t2.getTag().getLabel());
    assertEquals(1,t1.getCount());
    assertEquals(1,t1.getCount());
   
    tagDao.addTagCountOne(new Tag[]{new Tag(100)}, new User(1), new Link(202), new Bookmark(1));
    folderTags = folderDao.findTagsInFolder(new Folder(2), 0, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(3,folderTags.size());
    t1 = folderTags.get(0);
    t2 = folderTags.get(1);
    assertEquals(1,t1.getCount());
    assertEquals(1,t1.getCount());
View Full Code Here

    assertEquals(1,t3.getCount());
    assertEquals("newsnews",t3.getTag().getLabel());
  }

  public void testSubTagCountOne() throws Exception{
    List<FolderTag> folderTags = folderDao.findTagsInFolder(new Folder(2), 1, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
    FolderTag t1 = folderTags.get(0);
    FolderTag t2 = folderTags.get(1);
   
    assertEquals("cnn",t1.getTag().getLabel());
    assertEquals("news",t2.getTag().getLabel());
    assertEquals(1,t1.getCount());
    assertEquals(1,t1.getCount());
   
    tagDao.subtractTagCountOne(new Tag[]{new Tag(1)}, new User(1), new Link(202), new Bookmark(1));
    folderTags = folderDao.findTagsInFolder(new Folder(2), 1, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(1,folderTags.size());
    t1 = folderTags.get(0);
    assertEquals(1,t1.getCount());
    assertEquals("news",t1.getTag().getLabel());
  }
View Full Code Here

    assertEquals(1,bmtag11.getCount());
   
    BookmarkTag bmtagQ = tagDao.getBookmarkTag(12);
    assertEquals(0,bmtagQ.getCount());
   
    folderTags = folderDao.findTagsInFolder(new Folder(2), 0, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
   
    t1 = folderTags.get(0);
    assertEquals("cnn",t1.getTag().getLabel());
    assertEquals(1,t1.getCount());
    t2 = folderTags.get(1);
    assertEquals("news",t2.getTag().getLabel());
    assertEquals(1,t2.getTag().getCount());
   
    List<Bookmark> chngBmarks = tagDao.expandTag(new User(1), new Tag(1), new Tag[]{new Tag(4)});
    assertEquals(1,chngBmarks.size());
    for(Bookmark c : chngBmarks){
      assertTrue(c.getTagList().contains("questions"));
      assertTrue(c.getTagList().contains("cnn"));
    }
       
    cnnTag = tagDao.getTag(1);
    assertEquals(1,cnnTag.getCount());
   
    newsTag = tagDao.getTag(2);
    assertEquals(1,newsTag.getCount());
   
    ltag1 = tagDao.getLinkTag(1);
    assertEquals(1,ltag1.getCount());
   
    ltag2 = tagDao.getLinkTag(2);
    assertEquals(1,ltag2.getCount());
   
    bmtag10 = tagDao.getBookmarkTag(10);
    assertEquals(1,bmtag10.getCount());
   
    bmtag11 = tagDao.getBookmarkTag(11);
    assertEquals(1,bmtag11.getCount());
 
    bmtagQ = tagDao.getBookmarkTag(12);
    assertEquals(1,bmtagQ.getCount());
   
    folderTags = folderDao.findTagsInFolder(new Folder(2), 0, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(3,folderTags.size());
   
    t1 = folderTags.get(0);
    assertEquals("cnn",t1.getTag().getLabel());
    assertEquals(1,t1.getCount());
View Full Code Here

    assertNotNull(bmarks.getResult().get(0).getUser());
  }
 
  public void testAddBookmarksToFolders2() throws Exception{
    Date now = GregorianCalendar.getInstance().getTime();
    Folder f = new Folder("somenewfolder",new User(1),"",now);
    int id = folderDao.createFolder(f);
    assertTrue(id > 0);
   
    assertFalse(folderDao.hasFolderTag(new Folder(id),new Tag(1)));
    assertFalse(folderDao.hasFolderTag(new Folder(id),new Tag(3)));
   
    List<Bookmark> bmarks = new ArrayList<Bookmark>();
    bmarks.add(new Bookmark(300));
    boolean[] opOkay = folderDao.addBookmarks(new Folder(id),bmarks,now);
    for(boolean b: opOkay){
      assertTrue(b);
    }
     
    assertTrue(folderDao.hasFolderTag(new Folder(id),new Tag(1)));
    assertTrue(folderDao.hasFolderTag(new Folder(id),new Tag(3)));
   
    List<FolderTag> folderTags = folderDao.findTagsInFolder(new Folder(id),1,FolderDao.SORT_BY_ALPHA,FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
    assertEquals(1,folderTags.get(0).getCount());
    assertEquals(1,folderTags.get(1).getCount());
   
    bmarks = new ArrayList<Bookmark>();
    bmarks.add(new Bookmark(300)); // add again shouldn't affect the count
    bmarks.add(new Bookmark(301));
    opOkay = folderDao.addBookmarks(new Folder(id),bmarks,now);
    for(boolean b: opOkay){
      assertTrue(b);
    }
 
    folderTags = folderDao.findTagsInFolder(new Folder(id),1,FolderDao.SORT_BY_ALPHA,FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
    assertEquals(2,folderTags.get(0).getCount());
    assertEquals(2,folderTags.get(1).getCount());
  }
View Full Code Here

 
  public void testReduceTag() throws Exception{
    List<FolderTag> folderTags = null;
    FolderTag t1, t2;
   
    folderTags = folderDao.findTagsInFolder(new Folder(2), 1, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(2,folderTags.size());
   
    t1 = folderTags.get(0);
    assertEquals("cnn",t1.getTag().getLabel());
    assertEquals(1,t1.getCount());
    t2 = folderTags.get(1);
    assertEquals("news",t2.getTag().getLabel());
    assertEquals(1,t2.getTag().getCount());
   
    List<Bookmark> changeBookmarks= tagDao.reduceTag(new User(1), new Tag[]{new Tag(1)});
    assertEquals(1,changeBookmarks.size());
    for(Bookmark c : changeBookmarks){
      assertFalse(c.getTagList().contains("cnn"));
    }
   
    BookmarkTag bm11 = tagDao.getBookmarkTag(11);
    assertEquals("cnn",bm11.getTag().getLabel());
    assertEquals(0,bm11.getCount());
    assertEquals(0,bm11.getTag().getCount());
 
    LinkTag ln1 = tagDao.getLinkTag(1);
    assertEquals(202,ln1.getLink().getId());
    assertEquals(0,ln1.getCount());
    assertEquals(0,ln1.getTag().getCount());
   
    folderTags = folderDao.findTagsInFolder(new Folder(2), 1, FolderDao.SORT_BY_ALPHA, FolderDao.ASCENDING);
    assertEquals(1,folderTags.size());
   
    t1 = folderTags.get(0);
    assertEquals("news",t1.getTag().getLabel());
    assertEquals(1,t1.getCount());
View Full Code Here

    assertEquals(2,folderTags.get(0).getCount());
    assertEquals(2,folderTags.get(1).getCount());
  }

  public void testRemoveAllBookmarks() throws Exception {
    Folder f1 = folderDao.getFolder(1);
    assertEquals(3, f1.getSize());

    int cnt = folderDao.removeAllBookmarks(f1);
    assertEquals(3, cnt);

    f1 = folderDao.getFolder(1);
    assertEquals(0, f1.getSize());

    cnt = folderDao.removeAllBookmarks(f1);
    assertEquals(0, cnt);
  }
View Full Code Here

TOP

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

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.