@Test public void testFindRulesByCategory() throws Exception { getRepo().loadCategory( "/" ).addCategory( "testFindRulesByCat", "yeah" ); AssetItem as1 = getDefaultPackage().addAsset( "testFindRulesByCategory1", "ya", "testFindRulesByCat", "drl" ); getDefaultPackage().addAsset( "testFindRulesByCategory2", "ya", "testFindRulesByCat", AssetItem.DEFAULT_CONTENT_FORMAT ).checkin( "version0" ); as1.checkin( "version0" ); assertEquals("drl", as1.getFormat()); List rules = getRepo().findAssetsByCategory( "testFindRulesByCat", 0, -1 ).assets; assertEquals(2, rules.size()); for ( Iterator iter = rules.iterator(); iter.hasNext(); ) { AssetItem element = (AssetItem) iter.next(); assertTrue(element.getName().startsWith( "testFindRulesByCategory" )); } try { getRepo().loadCategory( "testFindRulesByCat" ).remove(); fail("should not be able to remove"); } catch (RulesRepositoryException e) { //assertTrue(e.getCause() instanceof ReferentialIntegrityException); assertNotNull(e.getMessage()); } }
@Test public void testRemoveCategoryUneeded() { RulesRepository repo = getRepo(); repo.loadCategory("/").addCategory("testRemoveCat", "a"); AssetItem as = repo.loadDefaultModule().addAsset("testRemoveCategory", "a", "testRemoveCat", "drl"); as.checkin("a"); as.updateCategoryList(new String[] {}); as.checkin("a"); as = repo.loadDefaultModule().loadAsset("testRemoveCategory"); assertEquals(0, as.getCategories().size()); repo.loadCategory("testRemoveCat").remove(); repo.save(); }
@Test public void testRemoveCategoryLinkedWithArchived() { RulesRepository repo = getRepo(); repo.loadCategory("/").addCategory("testRemoveCategoryWithArchivedCat", "a"); AssetItem as = repo.loadDefaultModule().addAsset("testRemoveCategoryWithArchivedAsset", "a", "testRemoveCategoryWithArchivedCat", "drl"); as.checkin("a"); as.archiveItem(true); repo.loadCategory("testRemoveCategoryWithArchivedCat").remove(); repo.save(); as.remove(); } /**
@Test public void testCreateCateories() throws Exception { RulesRepository repo = getRepo(); // load the root CategoryItem root = repo.loadCategory("/"); CategoryItem item = root.addCategory("testCreateCategories", "this is a top level one"); assertEquals("testCreateCategories", item.getName()); assertEquals("testCreateCategories", item.getFullPath()); item = repo.loadCategory("testCreateCategories"); assertEquals("testCreateCategories", item.getName()); item.remove(); repo.save(); try { repo.loadCategory("testCreateCategories"); fail("this should not exist"); } catch (RulesRepositoryException e) { assertNotNull(e.getCause()); } }
getRepo().loadCategory("testRemoveTagForShareableAssetTag2").remove(); fail("should not be able to remove"); } catch (RulesRepositoryException e) {