Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Tag


    assertEquals(1,rootCluster.size());
   
    List<Tag> tagKey = action.getTagClusterKey();
    assertEquals(1,tagKey.size());   
   
    Tag t0 = tagKey.get(0);
    assertEquals(0,t0.getId());
   
    List<Bookmark> bm = action.getBookmarks();
    assertEquals(1,bm.size());
    assertEquals(205,bm.get(0).getLink().getId());
  }
View Full Code Here


    assertEquals(1,userClusterMap.get("u1").size());
   
    List<Tag> tagKey = action.getTagClusterKey();
    assertEquals(2,tagKey.size());   
   
    Tag t1 = tagKey.get(0);
    Tag t2 = tagKey.get(1);
   
    Map<String,List<Integer>> tagClusterMap = action.getTagClusterMap();
    assertEquals(2,tagClusterMap.size());
   
    List<Integer> tc1 = tagClusterMap.get("t"+t1.getId());
    assertEquals(1,tc1.size());

    List<Integer> tc2 = tagClusterMap.get("t"+t2.getId());
    assertEquals(1,tc2.size());
   
    List<Bookmark> bm = action.getBookmarks();
    assertEquals(1,bm.size());
    assertEquals("title3 foobar2",bm.get(0).getTitle());
View Full Code Here

  protected IDataSet getDataSet() throws Exception {
    return new FlatXmlDataSet(TestEditBookmarkTag.class.getResourceAsStream("/TestEditBookmarkTag-input.xml"))
  }
 
  public void testRenameTag1() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("A");
    action.setNewTag("B");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(0,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(2),0,10).getResult();
    assertEquals(3,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(1,tagA.getCount());
    tagB = tagDao.getTag(2);
    assertEquals(3,tagB.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(0,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(0,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(1,linkTag1002_A.getCount());
   
    LinkTag linkTag1000_B = tagDao.findLinkTag(new Link(1000),new Tag(2)).get(0);
    assertEquals(1,linkTag1000_B.getCount());
    LinkTag linkTag1001_B = tagDao.findLinkTag(new Link(1001),new Tag(2)).get(0);
    assertEquals(1,linkTag1001_B.getCount());
    LinkTag linkTag1002_B = tagDao.findLinkTag(new Link(1002),new Tag(2)).get(0);
    assertEquals(1,linkTag1002_B.getCount());
   
    bm301 = bookmarkDao.getBookmark(301);
    assertFalse(bm301.getTagList().contains("A"));
    assertTrue(bm301.getTagList().contains("B"));
View Full Code Here

    assertTrue(bm304.getTagList().contains("A"));
    assertFalse(bm304.getTagList().contains("B"));
  }
 
  public void testRenameTag2() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    Tag tagC = tagDao.getTag(3);
    assertEquals(0,tagC.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("A");
    action.setNewTag("B C");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(0,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(2),0,10).getResult();
    assertEquals(3,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(3),0,10).getResult();
    assertEquals(3,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(1,tagA.getCount());
    tagB = tagDao.getTag(2);
    assertEquals(3,tagB.getCount());
    tagC = tagDao.getTag(3);
    assertEquals(3,tagC.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(0,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(0,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(1,linkTag1002_A.getCount());
   
    LinkTag linkTag1000_B = tagDao.findLinkTag(new Link(1000),new Tag(2)).get(0);
    assertEquals(1,linkTag1000_B.getCount());
    LinkTag linkTag1001_B = tagDao.findLinkTag(new Link(1001),new Tag(2)).get(0);
    assertEquals(1,linkTag1001_B.getCount());
    LinkTag linkTag1002_B = tagDao.findLinkTag(new Link(1002),new Tag(2)).get(0);
    assertEquals(1,linkTag1002_B.getCount());
   
    LinkTag linkTag1000_C = tagDao.findLinkTag(new Link(1000),new Tag(3)).get(0);
    assertEquals(1,linkTag1000_C.getCount());
    LinkTag linkTag1001_C = tagDao.findLinkTag(new Link(1001),new Tag(3)).get(0);
    assertEquals(1,linkTag1001_C.getCount());
    LinkTag linkTag1002_C = tagDao.findLinkTag(new Link(1002),new Tag(3)).get(0);
    assertEquals(1,linkTag1002_C.getCount());
   
    bm301 = bookmarkDao.getBookmark(301);
    assertFalse(bm301.getTagList().contains("A"));
    assertTrue(bm301.getTagList().contains("B"));
View Full Code Here

    assertFalse(bm304.getTagList().contains("B"));
    assertFalse(bm304.getTagList().contains("C"));
  }
 
  public void testRenameTag3() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    Tag tagC = tagDao.getTag(3);
    assertEquals(0,tagC.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("A");
    action.setNewTag("A B C");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(2),0,10).getResult();
    assertEquals(3,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(3),0,10).getResult();
    assertEquals(3,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    tagB = tagDao.getTag(2);
    assertEquals(3,tagB.getCount());
    tagC = tagDao.getTag(3);
    assertEquals(3,tagC.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
   
    LinkTag linkTag1000_B = tagDao.findLinkTag(new Link(1000),new Tag(2)).get(0);
    assertEquals(1,linkTag1000_B.getCount());
    LinkTag linkTag1001_B = tagDao.findLinkTag(new Link(1001),new Tag(2)).get(0);
    assertEquals(1,linkTag1001_B.getCount());
    LinkTag linkTag1002_B = tagDao.findLinkTag(new Link(1002),new Tag(2)).get(0);
    assertEquals(1,linkTag1002_B.getCount());
   
    LinkTag linkTag1000_C = tagDao.findLinkTag(new Link(1000),new Tag(3)).get(0);
    assertEquals(1,linkTag1000_C.getCount());
    LinkTag linkTag1001_C = tagDao.findLinkTag(new Link(1001),new Tag(3)).get(0);
    assertEquals(1,linkTag1001_C.getCount());
    LinkTag linkTag1002_C = tagDao.findLinkTag(new Link(1002),new Tag(3)).get(0);
    assertEquals(1,linkTag1002_C.getCount());
   
    bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    assertTrue(bm301.getTagList().contains("B"));
View Full Code Here

    assertFalse(bm304.getTagList().contains("B"));
    assertFalse(bm304.getTagList().contains("C"));
  }
 
  public void testRenameTag4() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    Tag tagC = tagDao.getTag(3);
    assertEquals(0,tagC.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("A");
    action.setNewTag("A B A B C");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(2),0,10).getResult();
    assertEquals(3,bmarks.size());
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(3),0,10).getResult();
    assertEquals(3,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    tagB = tagDao.getTag(2);
    assertEquals(3,tagB.getCount());
    tagC = tagDao.getTag(3);
    assertEquals(3,tagC.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
   
    LinkTag linkTag1000_B = tagDao.findLinkTag(new Link(1000),new Tag(2)).get(0);
    assertEquals(1,linkTag1000_B.getCount());
    LinkTag linkTag1001_B = tagDao.findLinkTag(new Link(1001),new Tag(2)).get(0);
    assertEquals(1,linkTag1001_B.getCount());
    LinkTag linkTag1002_B = tagDao.findLinkTag(new Link(1002),new Tag(2)).get(0);
    assertEquals(1,linkTag1002_B.getCount());
   
    LinkTag linkTag1000_C = tagDao.findLinkTag(new Link(1000),new Tag(3)).get(0);
    assertEquals(1,linkTag1000_C.getCount());
    LinkTag linkTag1001_C = tagDao.findLinkTag(new Link(1001),new Tag(3)).get(0);
    assertEquals(1,linkTag1001_C.getCount());
    LinkTag linkTag1002_C = tagDao.findLinkTag(new Link(1002),new Tag(3)).get(0);
    assertEquals(1,linkTag1002_C.getCount());
   
    bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    assertTrue(bm301.getTagList().contains("B"));
View Full Code Here

    assertFalse(bm304.getTagList().contains("B"));
    assertFalse(bm304.getTagList().contains("C"));
  }
 
  public void testDeleteTag1() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("A");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(0,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(1,tagA.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(0,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(0,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(1,linkTag1002_A.getCount());
     
    bm301 = bookmarkDao.getBookmark(301);
    assertFalse(bm301.getTagList().contains("A"));
    bm302 = bookmarkDao.getBookmark(302);
View Full Code Here

    bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
  }
 
  public void testDeleteTag2() throws Exception{
    List<Bookmark> bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());   
    bmarks = bookmarkDao.pageBookmarks(new User(1), new Tag(2),0,10).getResult();
    assertEquals(0,bmarks.size());
    Tag tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
    Tag tagB = tagDao.getTag(2);
    assertEquals(0,tagB.getCount());
    LinkTag linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    LinkTag linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    LinkTag linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
    Bookmark bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    Bookmark bm302 = bookmarkDao.getBookmark(302);
    assertTrue(bm302.getTagList().contains("A"));
    Bookmark bm303 = bookmarkDao.getBookmark(303);
    assertTrue(bm303.getTagList().contains("A"));
    Bookmark bm304 = bookmarkDao.getBookmark(304);
    assertTrue(bm304.getTagList().contains("A"));
   
    action.setTag("B");
    String code = action.execute();
    assertEquals(ActionSupport.SUCCESS,code);
   
    // delete a 0-usage-freq tag is allowed.
    assertNull(GnizrDaoUtil.getUserTag(tagDao, new User(1), new Tag(2)));
   
    bmarks = bookmarkDao.pageBookmarks(new User(1),new Tag(1),0,10).getResult();
    assertEquals(3,bmarks.size());
   
    tagA = tagDao.getTag(1);
    assertEquals(4,tagA.getCount());
   
    linkTag1000_A = tagDao.findLinkTag(new Link(1000),new Tag(1)).get(0);
    assertEquals(1,linkTag1000_A.getCount());
    linkTag1001_A = tagDao.findLinkTag(new Link(1001),new Tag(1)).get(0);
    assertEquals(1,linkTag1001_A.getCount());
    linkTag1002_A = tagDao.findLinkTag(new Link(1002),new Tag(1)).get(0);
    assertEquals(2,linkTag1002_A.getCount());
     
    bm301 = bookmarkDao.getBookmark(301);
    assertTrue(bm301.getTagList().contains("A"));
    bm302 = bookmarkDao.getBookmark(302);
View Full Code Here

    r  = dao.findTagAssertion(user3,null,new TagProperty(4),classTag201);
    assertEquals(0,r.size());
  }
 
  public void testFindRelatedTags() throws Exception{
    Tag tag_news = new Tag(2);
    List<Tag> result = dao.findRelatedTags(tag_news, 1);
    assertEquals(1, result.size());
   
    result = dao.findRelatedTags(tag_news, 1000);
    assertEquals(2, result.size());
   
    Tag t = result.get(0);
    assertNotNull(t.getLabel());
    assertTrue(t.getCount()>0);
  }
View Full Code Here

    assertEquals(id,bmDao.createBookmark(bm));
    assertTrue(bmDao.deleteBookmark(id));
  }
 
  public void testGetBookmarkCountOfTag() throws Exception{
    int cnt = bmDao.getBookmarkCount(new Tag(1));
    assertEquals(2,cnt);
   
    cnt = bmDao.getBookmarkCount(new Tag(3));
    assertEquals(2,cnt);
  }
View Full Code Here

TOP

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

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.