/**
   * Update categorized tags.
   *
   * @throws Exception the exception
   */
  @Test(
      groups = {"globalTagCategories"},
      dependsOnMethods = {"createCategorizedTags"})
  public void updateCategorizedTags() throws Exception {
    TagCategoryManagement tm = ServiceLocator.findService(TagCategoryManagement.class);
    GlobalTagCategory categoryTwo = loadGlobalTagCategory(GLOBAL_TAG_CATEGORY2_PREFIX);
    List<CategorizedTag> tags = tm.getCategorizedTags(categoryTwo.getId());
    Assert.assertNotNull(tags, "tags can not be null");
    Assert.assertTrue(tags.size() > 2, "taglist must have at least three elements");

    CategorizedTag tag = tags.get(0);
    Assert.assertNotNull(tag, "tag can not be null");
    LOG.debug("rename tag " + tag.getName() + " to 'rename_first'");
    CategorizedTagVO categorizedTagVO = new CategorizedTagVO("rename_first");
    tag = tm.updateCategorizedTag(tag.getId(), categorizedTagVO);
    checkTagData(categorizedTagVO, tag);
    checkTagIndex(tm.getCategorizedTags(categoryTwo.getId()), tag, 0);

    tag = tags.get(1);
    Assert.assertNotNull(tag, "tag can not be null");
    LOG.debug("move tag " + tag.getName() + " to the end");
    LOG.debug("current tag order:");
    for (int i = 0; i < tags.size(); i++) {
      CategorizedTag t = tags.get(i);
      LOG.debug(i + ". " + t.getId() + " - " + categoryTwo.getPrefix() + ":" + t.getName());
    }
    tm.changeCategorizedTagIndex(tag.getId(), tags.size() - 1);
    tags = tm.getCategorizedTags(categoryTwo.getId());
    LOG.debug("new tag order:");
    for (int i = 0; i < tags.size(); i++) {
      CategorizedTag t = tags.get(i);
      LOG.debug(i + ". " + t.getId() + " - " + categoryTwo.getPrefix() + ":" + t.getName());
    }
    checkTagIndex(tags, tag, tags.size() - 1);
  }
 /**
  * Compares the data of an tag entity and its value object.
  *
  * @param expected the expected values
  * @param actual the actual values
  */
 private void checkTagData(CategorizedTagVO expected, CategorizedTag actual) {
   Assert.assertEquals(expected.getName(), actual.getName(), "tag names not equal");
   Assert.assertEquals(
       expected.getName().toLowerCase(), actual.getTagStoreTagId(), "lower names not equal");
 }