public void testCategory() throws Exception { String[] catIds = new String[] {getId(Utils.CATEGORY), getId(Utils.CATEGORY), getId(Utils.CATEGORY)}; // add category forumService_.saveCategory(createCategory(catIds[0]), true); forumService_.saveCategory(createCategory(catIds[1]), true); forumService_.saveCategory(createCategory(catIds[2]), true); Category category = forumService_.getCategory(catIds[0]); assertNotNull("Category is null", category); // get categories List<Category> categories = forumService_.getCategories(); assertEquals(categories.size(), 3); // update category category.setCategoryName("ReName Category"); forumService_.saveCategory(category, false); Category updatedCat = forumService_.getCategory(catIds[0]); assertEquals("Category name is not change", "ReName Category", updatedCat.getCategoryName()); // test removeCategory for (int i = 0; i < 3; ++i) { forumService_.removeCategory(catIds[i]); } categories = forumService_.getCategories(); assertEquals("Size categories can not equals 0", categories.size(), 0); }
public void setCategoryValue(Category category, boolean isUpdate) throws Exception { if (isUpdate) { this.categoryId = category.getId(); getUIStringInput(FIELD_CATEGORYTITLE_INPUT) .setValue(CommonUtils.decodeSpecialCharToHTMLnumber(category.getCategoryName())); getUIStringInput(FIELD_CATEGORYORDER_INPUT) .setValue(Long.toString(category.getCategoryOrder())); getUIFormTextAreaInput(FIELD_DESCRIPTION_INPUT) .setDefaultValue(CommonUtils.decodeSpecialCharToHTMLnumber(category.getDescription())); String userPrivate = ForumUtils.unSplitForForum(category.getUserPrivate()); getUIFormTextAreaInput(FIELD_USERPRIVATE_MULTIVALUE).setValue(userPrivate); UIPermissionPanel permissionTab = getChildById(PERMISSION_TAB); permissionTab.addPermissionForOwners(MODERAROR, category.getModerators()); permissionTab.addPermissionForOwners(TOPICABLE, category.getCreateTopicRole()); permissionTab.addPermissionForOwners(POSTABLE, category.getPoster()); permissionTab.addPermissionForOwners(VIEWER, category.getViewer()); } }
private void injectForum() throws Exception { // String forumName = forumBase + toType; Forum forum = getForumByName(forumName); if (forum == null) { getLog() .info( "forum name is '" + forumName + "' is wrong. Please set it exactly. Aborting injection ..."); return; } Category cat = getCategoryByForumName(forumName); // String[] userNames = getUserNames(); if (userNames == null | userNames.length <= 0) { getLog() .info( "Don't assign permission any user to '" + forumName + "' forum. Please set it exactly. Aborting injection ..."); return; } // forum = forumService.getForum(cat.getId(), forum.getId()); forum.setModerators(userNames); forum.setCreateTopicRole(userNames); forum.setViewer(userNames); forum.setPoster(userNames); forumService.saveForum(cat.getId(), forum, false); getLog() .info( "Assign permission '" + Arrays.toString(userNames) + "' user(s) into '" + forumName + "' forum in '" + cat.getCategoryName() + "' category."); }
private String stringCategoryProcess(List<String> values) { StringBuilder outPut = new StringBuilder(); if (!values.isEmpty()) { for (String value : values) { if (!ForumUtils.isEmpty(value)) { if (value.indexOf('(') > 0) { String forumSubPath = value.substring(value.lastIndexOf('(')).replace("(", ""); String categoryId = forumSubPath.split("/")[0]; Category category = getForumService().getCategory(categoryId); if (category != null) { outPut.append(category.getCategoryName() + "\n"); } else { removeItemContainsInList(listModCate, categoryId); removeItemContainsInList(listModerate, categoryId); } } } } } return outPut.toString(); }