@Test
public void rgtLftCategoryTest(){
categoryDao.getHibernateTemplate().deleteAll(categoryDao.getHibernateTemplate().loadAll(Category.class));
//This is the root, should be always consistent (rgt is the max of all rgt, lft is 0)
Category category = aCategoryWithPath("ROOT", "root", "", 0);
categoryDao.save(category);
joomlaJavaApi.createCategoriesInCascade("Sud America/Ecuador");
categoryDao.rebuildCategoryTree();
//Assert root category
List<Category> categoryFromPath = categoryDao.getCategoryFromPath("");
Category rootCategory = categoryFromPath.get(0);
assertThat(rootCategory.getLft(),is(0));
assertThat(rootCategory.getRgt(),is(5));
//Assert brand new category
categoryFromPath = categoryDao.getCategoryFromPath("sud-america/ecuador");
Category newCategory = categoryFromPath.get(0);
assertThat(newCategory.getLft(),is(2));
assertThat(newCategory.getRgt(),is(3));
categoryFromPath = categoryDao.getCategoryFromPath("sud-america");
newCategory = categoryFromPath.get(0);
assertThat(newCategory.getLft(),is(1));
assertThat(newCategory.getRgt(),is(4));
}