assertNotNull(folder);
List menus = folder.getMenuDefinitions();
assertNotNull(menus);
assertEquals(5, menus.size());
MenuDefinition simpleMenu = (MenuDefinition)menus.get(0);
assertNotNull(simpleMenu);
assertEquals("simple", simpleMenu.getName());
assertNotNull(simpleMenu.getMenuElements());
assertEquals(1, simpleMenu.getMenuElements().size());
assertTrue(simpleMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
assertEquals("/test001.psml,/folder1/folder2", ((MenuOptionsDefinition)simpleMenu.getMenuElements().get(0)).getOptions());
MenuDefinition top2LevelsMenu = (MenuDefinition)menus.get(1);
assertNotNull(top2LevelsMenu);
assertEquals("top-2-levels", top2LevelsMenu.getName());
assertNull(top2LevelsMenu.getMenuElements());
assertEquals("/", top2LevelsMenu.getOptions());
assertEquals(2, top2LevelsMenu.getDepth());
assertEquals("dhtml-pull-down", top2LevelsMenu.getSkin());
MenuDefinition topRolePagesMenu = (MenuDefinition)menus.get(2);
assertNotNull(topRolePagesMenu);
assertEquals("top-role-pages", topRolePagesMenu.getName());
assertTrue(topRolePagesMenu.isRegexp());
assertEquals("roles", topRolePagesMenu.getProfile());
assertEquals("*.psml,*.link", topRolePagesMenu.getOrder());
MenuDefinition breadCrumbsMenu = (MenuDefinition)menus.get(3);
assertNotNull(breadCrumbsMenu);
assertEquals("bread-crumbs", breadCrumbsMenu.getName());
assertTrue(breadCrumbsMenu.isPaths());
MenuDefinition topCustomMenu = (MenuDefinition)menus.get(4);
assertNotNull(topCustomMenu);
assertEquals("top-custom", topCustomMenu.getName());
assertEquals("Top Menu", topCustomMenu.getTitle());
assertEquals("Top", topCustomMenu.getShortTitle());
assertEquals("Haut", topCustomMenu.getTitle(Locale.FRENCH));
assertEquals("H", topCustomMenu.getShortTitle(Locale.FRENCH));
assertNotNull(topCustomMenu.getMenuElements());
assertEquals(5, topCustomMenu.getMenuElements().size());
assertTrue(topCustomMenu.getMenuElements().get(0) instanceof MenuOptionsDefinition);
assertTrue(((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).isRegexp());
assertEquals("groups", ((MenuOptionsDefinition)topCustomMenu.getMenuElements().get(0)).getProfile());
assertTrue(topCustomMenu.getMenuElements().get(1) instanceof MenuDefinition);
assertTrue(topCustomMenu.getMenuElements().get(2) instanceof MenuExcludeDefinition);
assertEquals("top-role-pages", ((MenuExcludeDefinition)topCustomMenu.getMenuElements().get(2)).getName());
assertTrue(topCustomMenu.getMenuElements().get(3) instanceof MenuSeparatorDefinition);
assertEquals("More Top Pages", ((MenuSeparatorDefinition)topCustomMenu.getMenuElements().get(3)).getText());
assertTrue(topCustomMenu.getMenuElements().get(4) instanceof MenuIncludeDefinition);
assertEquals("simple", ((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).getName());
assertTrue(((MenuIncludeDefinition)topCustomMenu.getMenuElements().get(4)).isNest());
MenuDefinition topCustomNestedMenu = (MenuDefinition)topCustomMenu.getMenuElements().get(1);
assertEquals("/", topCustomNestedMenu.getOptions());
assertEquals("page", topCustomNestedMenu.getProfile());
assertEquals(5, topCustomNestedMenu.getMenuElements().size());
assertTrue(topCustomNestedMenu.getMenuElements().get(0) instanceof MenuSeparatorDefinition);
assertEquals("Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText());
assertEquals("Ye Olde Top Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getText(Locale.ENGLISH));
assertEquals("Select from Top Pages menu...", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle());
assertEquals("Haut", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(0)).getTitle(Locale.FRENCH));
assertTrue(topCustomNestedMenu.getMenuElements().get(1) instanceof MenuOptionsDefinition);
assertTrue(topCustomNestedMenu.getMenuElements().get(2) instanceof MenuSeparatorDefinition);
assertEquals("bold", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getSkin());
assertEquals("Custom Pages", ((MenuSeparatorDefinition)topCustomNestedMenu.getMenuElements().get(2)).getTitle());
assertTrue(topCustomNestedMenu.getMenuElements().get(3) instanceof MenuOptionsDefinition);
assertEquals(1, ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getDepth());
assertEquals("*.psml", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(3)).getOrder());
assertTrue(topCustomNestedMenu.getMenuElements().get(4) instanceof MenuOptionsDefinition);
assertTrue(((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).isPaths());
assertEquals("*", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getProfile());
assertEquals("links", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getSkin());
assertEquals("@", ((MenuOptionsDefinition)topCustomNestedMenu.getMenuElements().get(4)).getOptions());
// test page resident menu definitions
Page page = pageManager.getPage("/test001.psml");
assertNotNull(page);
menus = page.getMenuDefinitions();
assertNotNull(menus);
assertEquals(1, menus.size());
simpleMenu = (MenuDefinition)menus.get(0);
assertNotNull(simpleMenu);
assertEquals("simple", simpleMenu.getName());
assertNotNull(simpleMenu.getMenuElements());
assertEquals(2, simpleMenu.getMenuElements().size());
// test writing page menu definitions
page = pageManager.getPage(this.testPage002);
page.setMenuDefinitions(new ArrayList());
MenuDefinition newMenu = page.newMenuDefinition();
newMenu.setName("updated-menu");
newMenu.setSkin("tabs");
newMenu.setMenuElements(new ArrayList());
MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
newSeparator.setText("-- Updated Menu --");
newMenu.getMenuElements().add(newSeparator);
MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
newOptions0.setOptions("/*.psml");
newOptions0.setRegexp(true);
newMenu.getMenuElements().add(newOptions0);
MenuOptionsDefinition newOptions1 = page.newMenuOptionsDefinition();
newOptions1.setOptions("/folder0");
newMenu.getMenuElements().add(newOptions1);
MenuDefinition newNestedMenu = page.newMenuDefinition();
newNestedMenu.setOptions("/*/");
newNestedMenu.setRegexp(true);
newMenu.getMenuElements().add(newNestedMenu);
MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
newExcludeMenu.setName("exclude-menu");
newMenu.getMenuElements().add(newExcludeMenu);
MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();