public void testBasicCRUD() throws Exception {
log.info("BEGIN");
WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
WeblogCategory cat = null;
List cats = null;
// root category is always available
testWeblog = TestUtils.getManagedWebsite(testWeblog);
WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
// make sure we are starting with 0 categories (beneath root)
assertEquals(0, root.getWeblogCategories().size());
// add a new category
WeblogCategory newCat = new WeblogCategory(testWeblog, root, "catTestCategory", null, null);
mgr.saveWeblogCategory(newCat);
TestUtils.endSession(true);
// make sure category was added
cat = null;
cat = mgr.getWeblogCategory(newCat.getId());
assertNotNull(cat);
assertEquals(newCat, cat);
// make sure category count increased
testWeblog = TestUtils.getManagedWebsite(testWeblog);
root = mgr.getRootWeblogCategory(testWeblog);
assertEquals(1, root.getWeblogCategories().size());
// update category
cat.setName("testtest");
mgr.saveWeblogCategory(cat);
TestUtils.endSession(true);
// verify category was updated
cat = null;
cat = mgr.getWeblogCategory(newCat.getId());
assertNotNull(cat);
assertEquals("testtest", cat.getName());
// remove category
mgr.removeWeblogCategory(cat);
TestUtils.endSession(true);
// make sure cat was removed
cat = null;
cat = mgr.getWeblogCategory(newCat.getId());
assertNull(cat);
// make sure category count decreased
testWeblog = TestUtils.getManagedWebsite(testWeblog);
root = mgr.getRootWeblogCategory(testWeblog);