@Test public void testLoadRuleListForCategoryFullResults() throws Exception { ServiceImplementation impl = getServiceImplementation(); RepositoryPackageService repositoryPackageService = getRepositoryPackageService(); RepositoryCategoryService repositoryCategoryService = getRepositoryCategoryService(); String cat = "testCategory"; repositoryCategoryService.createCategory("/", cat, "testCategoryDescription"); repositoryPackageService.createPackage( "testCategoryPackage", "testCategoryPackageDescription", "package"); impl.createNewRule( "testTextRule1", "testCategoryRule1", cat, "testCategoryPackage", AssetFormats.DRL); impl.createNewRule( "testTextRule2", "testCategoryRule2", cat, "testCategoryPackage", AssetFormats.DRL); impl.createNewRule( "testTextRule3", "testCategoryRule3", cat, "testCategoryPackage", AssetFormats.DRL); CategoryPageRequest request = new CategoryPageRequest(cat, 0, null); PageResponse<CategoryPageRow> response; response = repositoryCategoryService.loadRuleListForCategories(request); assertNotNull(response); assertNotNull(response.getPageRowList()); assertTrue(response.getStartRowIndex() == 0); assertTrue(response.getPageRowList().size() == 3); assertTrue(response.isLastPage()); }
@Test public void testAddCategories() throws Exception { ServiceImplementation impl = getServiceImplementation(); RepositoryCategoryService repositoryCategoryService = getRepositoryCategoryService(); impl.getRulesRepository().createPackage("testAddCategoriesPackage", "desc"); repositoryCategoryService.createCategory("", "testAddCategoriesCat1", "this is a cat"); repositoryCategoryService.createCategory("", "testAddCategoriesCat2", "this is a cat"); String uuid = impl.createNewRule( "testCreateNewRuleName", "an initial desc", "testAddCategoriesCat1", "testAddCategoriesPackage", AssetFormats.DSL_TEMPLATE_RULE); AssetItem dtItem = impl.getRulesRepository().loadAssetByUUID(uuid); dtItem.addCategory("testAddCategoriesCat1"); impl.getRulesRepository().save(); AssetItem dtItem1 = impl.getRulesRepository().loadAssetByUUID(uuid); assertEquals(1, dtItem1.getCategories().size()); assertTrue(dtItem1.getCategorySummary().contains("testAddCategoriesCat1")); AssetItem dtItem2 = impl.getRulesRepository().loadAssetByUUID(uuid); dtItem2.addCategory("testAddCategoriesCat2"); impl.getRulesRepository().save(); AssetItem dtItem3 = impl.getRulesRepository().loadAssetByUUID(uuid); assertEquals(2, dtItem3.getCategories().size()); assertTrue(dtItem3.getCategorySummary().contains("testAddCategoriesCat2")); }