assertEquals("news",t1.getTag().getLabel());
}
public void testExpandTag() throws Exception{
List<FolderTag> folderTags = null;
FolderTag t1, t2, t3;
BookmarkDao bmarkDao = new BookmarkDBDao(getDataSource());
Bookmark bm = bmarkDao.getBookmark(1);
List<String> tags = bm.getTagList();
assertTrue(tags.contains("cnn"));
assertTrue(tags.contains("news"));
Tag cnnTag = tagDao.getTag(1);
assertEquals(1,cnnTag.getCount());
Tag newsTag = tagDao.getTag(2);
assertEquals(1,newsTag.getCount());
LinkTag ltag1 = tagDao.getLinkTag(1);
assertEquals(1,ltag1.getCount());
LinkTag ltag2 = tagDao.getLinkTag(2);
assertEquals(1,ltag2.getCount());
BookmarkTag bmtag10 = tagDao.getBookmarkTag(10);
assertEquals(1,bmtag10.getCount());
BookmarkTag bmtag11 = tagDao.getBookmarkTag(11);
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());
t2 = folderTags.get(1);
assertEquals("news",t2.getTag().getLabel());
assertEquals(1,t2.getTag().getCount());
t3 = folderTags.get(2);
assertEquals("questions",t3.getTag().getLabel());