/** CaseID: 75276 Check topic activity after create topic */
  @Test
  public void test02_CheckTopicASafterCreateTopic() {
    String titleCat = "Category 02";
    String titleForum = "Forum 02";
    String titleTop = "Topic 02";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";
    String reply = "Reply on this topic";

    info("Create new Topic");
    //		create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    mngPost.postReply(reply, reply, "", "", "");

    mngTopic.voteTopic(1);

    navTool.goToHomePage();
    waitForAndGetElement(By.linkText(titleTop));
    hpgAct.checkNumberOfLineOfContent(
        getText(hpgAct.ELEMENT_FORUM_ACT_CONTENT.replace("${title}", titleTop)), descTop);
    hpgAct.checkRateTopic(titleTop, 1.0);
    hpgAct.checkReplyForum(titleTop, reply);

    // Delete data
    goToForums();
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75288 Jump to related reply */
  @Test
  public void test09_OpenRelatedReply() {
    String titleCat = "Category 09";
    String titleForum = "Forum 09";
    String titleTop = "Topic 09";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";
    String reply = "Reply to this topic 1";

    info("Jump to related reply");

    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    mngPost.postReply(reply, reply, "", "", "");

    // Check activity
    navTool.goToHomePage();

    if (waitForAndGetElement(By.linkText(titleTop), DEFAULT_TIMEOUT, 0) == null)
      driver.navigate().refresh();

    hpgAct.viewReplyFromActivity(titleTop, reply);

    // Delete data
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75275 Check topic AS after Move a topic */
  @Test
  public void test01_CheckTopicASafterMoveTopic() {
    String titleCat = "Category 01";
    String titleForum = "Forum 01";
    String titleTop = "Topic 01";
    String forum2 = "Forum 02";
    String[] addForum2 = {forum2, "1", null, null, forum2};
    String[] permission = {};

    info("Move a topic");
    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, titleTop);
    click(By.linkText(titleCat));
    waitForElementNotPresent(ELEMENT_BREAD_FORUM.replace("${forum}", titleForum));

    // Create a forum - destination
    mngFru.addForum(titleCat, addForum2, true, "", "", false, 0, permission);

    // Move topic
    click(By.linkText(titleCat));
    click(By.linkText(titleForum));
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    waitForAndGetElement(mngPost.ELEMENT_POST_REPLY_BUTTON);
    mngTopic.moveTopic(titleTop, forum2);

    // Check activity
    navTool.goToHomePage();
    hpgAct.checkCommentAfterMoveTopic(titleTop, titleCat + ">" + forum2);

    // Delete data
    goToForums();
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75287 Jump into last Reply of Topic */
  @Test
  public void test08_OpenLastReplyOfTopic() {
    String titleCat = "Category 08";
    String titleForum = "Forum 08";
    String titleTop = "Topic 08";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";
    String reply1 = "Reply to this topic 1";
    String reply2 = "Reply to this topic 2";

    info("Jump into last Reply of Topic");

    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    mngPost.postReply(reply1, reply1, "", "", "");
    mngPost.postReply(reply2, reply2, "", "", "");

    // Check activity
    navTool.goToHomePage();
    driver.navigate().refresh();
    waitForAndGetElement(By.linkText(titleTop));

    hpgAct.openLastReplyFromActivity(titleTop, reply2);

    // Delete data
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75280 Check topic activity after Delete topic */
  @Test
  public void test06_CheckTopicASafterDeleteTopic() {
    String titleCat = "Category 06";
    String titleForum = "Forum 06";
    String titleTop = "Topic 06";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";

    info("Delete topic");
    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));

    navTool.goToHomePage();
    waitForAndGetElement(By.linkText(titleTop));

    goToForums();
    mngTopic.deleteTopic(titleTop);

    navTool.goToHomePage();
    assert waitForAndGetElement(By.linkText(titleTop), 5000, 0) == null;

    // Delete data
    goToForums();
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75279 Check topic activity after Lock/Unlock a topic */
  @Test
  public void test05_CheckTopicASafterLockUnlockTopic() {
    String titleCat = "Category 05";
    String titleForum = "Forum 05";
    String titleTop = "Topic 05";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";

    info("Lock/Unlock a topic");
    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    // Lock a topic
    mngTopic.actionOnTopic(1);

    // Check if topic AS is updated or not after lock topic
    navTool.goToHomePage();
    hpgAct.checkLockTopic(titleTop);

    // Unlock a topic
    goToForums();
    mngTopic.actionOnTopic(2);

    // Check if topic AS is updated or not after unlock topic
    navTool.goToHomePage();
    hpgAct.checkUnlockTopic(titleTop);

    // Delete data
    goToForums();
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseId: 68917 -> Ban IP */
  @Test
  public void test02_BanIP() {
    String catName = "CategoryBanIP_02";
    String description = "Add new category in forum";
    String forumName = "ForumBanIP_02";
    String topic = "TopicBanIP_02";
    String message = "New topic 02";

    info("Add new category, forum, topic with user admin");
    cat.addNewCategoryInForum(catName, "1", 0, null, description, 0, null);
    forum.quickAddForum(forumName);
    magtopic.quickStartTopic(topic, message);

    String ip = Utils.getIPOfLocal();

    info("Set banIP is localhost");
    setBanIp(ip);
    magAc.signOut();

    info("Check banIp with user demo");
    driver.get("http://" + ip + ":8080/portal");
    magAc.signIn("demo", "gtn");
    goToForums();
    click(By.linkText(forumName));
    waitForAndGetElement(ELEMENT_START_TOPIC_DISABLE);
    waitForTextPresent(MSG_BLOCK_CREATE_TOPIC);
    waitForTextPresent(MSG_BLOCK_POST);
    waitForTextPresent(MSG_BLOCK_POST_ATTACHMENT);
    waitForTextPresent(MSG_BLOCK_EDIT_YOUR_POST);

    click(By.linkText(topic));
    waitForAndGetElement(ELEMENT_POST_DISABLE);
    waitForTextPresent(MSG_BLOCK_CREATE_TOPIC);
    waitForTextPresent(MSG_BLOCK_POST);
    waitForTextPresent(MSG_BLOCK_POST_ATTACHMENT);
    waitForTextPresent(MSG_BLOCK_EDIT_YOUR_POST);
    magAc.signOut();

    driver.get(baseUrl);
    magAc.signIn("john", "gtn");
    goToForums();
    deleteBanIp(ip);
    click(By.linkText(catName));
    cat.deleteCategoryInForum(catName);
  }
  /** CaseID: 75286 Jump into Reply form by clicking on "Reply" action */
  @Test
  public void test07_OpenReplyFormByClickReplyOnActivity() {
    String titleCat = "Category 07";
    String titleForum = "Forum 07";
    String titleTop = "Topic 07";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";

    info("Jump into Reply form by clicking on Reply action");

    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);

    // Check activity
    navTool.goToHomePage();
    driver.navigate().refresh();
    waitForAndGetElement(By.linkText(titleTop));

    hpgAct.openReplyFormFromActivity(titleTop);

    // Delete data
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /** CaseID: 75278 Check update Topic activity after Update topic content */
  @Test
  public void test04_CheckTopicASafterUpdateTopicContent() {
    String titleCat = "Category 04";
    String titleForum = "Forum 04";
    String titleTop = "Topic 04";
    String descTop = "line1<br>line2<br>line3<br>line4<br>line5";
    String newDesc = "New<br>";
    String[] userGroup = {};

    info("Update topic title");
    // create category, forum, topic
    mngTopic.addCategoryForumTopic(titleCat, titleForum, titleTop, descTop);
    click(mngFru.ELEMENT_TOPIC_LINK.replace("${topic}", titleTop));
    mngTopic.editTopic(titleTop, newDesc, "", 0, userGroup, false, false, false);

    navTool.goToHomePage();
    waitForAndGetElement(By.linkText(titleTop));
    hpgAct.checkUpdateTopic(titleTop, newDesc + descTop);

    // Delete data
    goToForums();
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }
  /**
   * Case ID:107032. Test Case Name: Move Post of normal users by Administrator. Pre-Condition:
   * Post-Condition: Done with OSs and browsers : Generated by phuongdt at 2014/01/22 10:24:54
   */
  @Test
  public void test01_MovePostOfNormalUsersByAdministrator() {
    String titleCat = "Category " + getRandomNumber();
    String titleForum = "Forum " + getRandomNumber();
    String titleTop1 = "Topic " + getRandomNumber();
    String titleTop2 = "Topic " + getRandomNumber();
    String post1 = "Post " + getRandomNumber();

    info("Test 01 Move Post of normal users by Administrator");
    /*Step Number: 1
    *Step Name: Step 1: Create topic
    *Step Description:
    	- Login as administrator to create a new category, forum, 2 topics"Topic A.1.1" and "To move demo's post"
    *Input Data:

    *Expected Outcome:
    	- Categories, forums, topics are created*/
    mngFru.addCategoryForum(titleCat, titleForum);
    click(mngTopic.ELEMENT_START_TOPIC_BUTTON);
    mngTopic.startTopic(titleTop1, titleTop1, "", 0, null, true, true);
    click(mngTopic.ELEMENT_START_TOPIC_BUTTON);
    mngTopic.startTopic(titleTop2, titleTop2, "", 0, null, true, true);

    /*Step number: 2
    *Step Name: Step 2: Add post(s) by normal users
    *Step Description:
    	- Log in as demo
    	- Post a reply to "Topic A.1.1"
    *Input Data:

    *Expected Outcome:
    	- Post(s) is created*/
    magAc.signIn(DATA_USER4, DATA_PASS1);
    goToForums();
    click(By.linkText(titleForum));
    click(By.linkText(titleTop1));
    mngPost.postReply(post1, post1, "", "");

    /*Step number: 3
    *Step Name: Step 3: Move post by Admin
    *Step Description:
    	- Login as admin
    	- Move demo's post from "Topic A.1.1" to "To move demo's post"
    *Input Data:

    *Expected Outcome:
    	This post is removed from "Topic A.1.1" and move to "To move demo's post"*/
    magAc.userSignIn(userType.ADMIN);
    goToForums();
    click(By.linkText(titleForum));
    click(By.linkText(titleTop1));
    mngPost.movePost(post1, titleCat + "/" + titleForum + "/" + titleTop2);

    /*Step number: 4
    *Step Name: Step 4: Move to Other topic
    *Step Description:
    	- Move again demo's post from "To move demo's post" to another topic
    *Input Data:

    *Expected Outcome:
    	Move successfully and no Ui error no exception in console*/
    click(By.linkText(titleCat));
    click(By.linkText(titleForum));
    click(By.linkText(titleTop2));
    mngPost.movePost(post1, titleCat + "/" + titleForum + "/" + titleTop1);

    // Clear data
    info("Clear data");
    click(By.linkText(titleCat));
    mngCat.deleteCategoryInForum(titleCat, true);
  }