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) */