@Override
  protected void validateImport(
      Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    List<StagedModel> dependentStagedModels =
        dependentStagedModelsMap.get(MBCategory.class.getSimpleName());

    Assert.assertEquals(1, dependentStagedModels.size());

    MBCategory category = (MBCategory) dependentStagedModels.get(0);

    MBCategoryLocalServiceUtil.getMBCategoryByUuidAndGroupId(
        category.getUuid(), group.getGroupId());
  }
  @Override
  protected long addContainerModel(long userId, long containerModelId) throws Exception {

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(group.getGroupId(), userId);

    MBCategory category =
        MBCategoryServiceUtil.addCategory(
            userId,
            containerModelId,
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            serviceContext);

    return category.getCategoryId();
  }
  @Override
  public List<Long> getSubcategoryIds(List<Long> categoryIds, long groupId, long categoryId) {

    List<MBCategory> categories = mbCategoryPersistence.filterFindByG_P(groupId, categoryId);

    for (MBCategory category : categories) {
      if (category.isInTrash()) {
        continue;
      }

      categoryIds.add(category.getCategoryId());

      getSubcategoryIds(categoryIds, category.getGroupId(), category.getCategoryId());
    }

    return categoryIds;
  }
  protected long getCategoryId(MBCategory category) {
    long categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID;

    if (category != null) {
      categoryId = category.getCategoryId();
    }

    return categoryId;
  }
  @Override
  protected BaseModel<?> addBaseModelWithWorkflow(
      BaseModel<?> parentBaseModel,
      boolean approved,
      String keywords,
      ServiceContext serviceContext)
      throws Exception {

    MBCategory category = (MBCategory) parentBaseModel;

    return MBTestUtil.addMessageWithWorkflow(
        serviceContext.getUserId(),
        category.getGroupId(),
        category.getCategoryId(),
        RandomTestUtil.randomString(),
        keywords,
        approved,
        serviceContext);
  }
  @Override
  protected StagedModel addStagedModel(
      Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception {

    List<StagedModel> dependentStagedModels =
        dependentStagedModelsMap.get(MBCategory.class.getSimpleName());

    MBCategory category = (MBCategory) dependentStagedModels.get(0);

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(group.getGroupId(), TestPropsValues.getUserId());

    return MBCategoryServiceUtil.addCategory(
        TestPropsValues.getUserId(),
        category.getCategoryId(),
        RandomTestUtil.randomString(),
        StringPool.BLANK,
        serviceContext);
  }
  public static void addPortletBreadcrumbEntries(
      MBCategory category, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/select_category");
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("categories"), portletURL.toString());
    } else {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view");
    }

    PortalUtil.addPortletBreadcrumbEntry(
        request, themeDisplay.translate("home"), portletURL.toString());

    if (category == null) {
      return;
    }

    if (!mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
    }

    List<MBCategory> ancestorCategories = category.getAncestors();

    Collections.reverse(ancestorCategories);

    for (MBCategory curCategory : ancestorCategories) {
      portletURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));

      PortalUtil.addPortletBreadcrumbEntry(request, curCategory.getName(), portletURL.toString());
    }

    portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, category.getName(), portletURL.toString());
  }
  @Override
  protected void validateImportedStagedModel(
      StagedModel stagedModel, StagedModel importedStagedModel) throws Exception {

    super.validateImportedStagedModel(stagedModel, importedStagedModel);

    MBCategory category = (MBCategory) stagedModel;
    MBCategory importedCategory = (MBCategory) importedStagedModel;

    Assert.assertEquals(category.getName(), importedCategory.getName());
    Assert.assertEquals(category.getDescription(), importedCategory.getDescription());
    Assert.assertEquals(category.getDisplayStyle(), importedCategory.getDisplayStyle());
    Assert.assertEquals(category.getThreadCount(), importedCategory.getThreadCount());
    Assert.assertEquals(category.getMessageCount(), importedCategory.getMessageCount());
    Assert.assertEquals(category.getLastPostDate(), importedCategory.getLastPostDate());
  }