Example #1
0
  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);
  }
Example #2
0
 private void killData() throws Exception {
   List<Category> cats = forumService_.getCategories();
   if (cats.size() > 0) {
     for (Category category : cats) {
       forumService_.removeCategory(category.getId());
     }
   }
 }