assertSame( menu, sub.getRoot() );
}
@Test
public void menuLevelsAreDynamicallyCalculated() {
Menu menu = new Menu( "", "" );
assertEquals( Menu.ROOT_LEVEL, menu.getLevel() );
Menu item1 = menu.addItem( "path1" );
Menu item2 = menu.addItem( "path2" );
Menu subItem1 = item2.addItem( "sub1" );
Menu subItem2 = item2.addItem( "sub2" );
Menu subSubItem1 = subItem1.addItem( "subsub1" );
Menu subSubItem2 = subItem2.addItem( "subsub2" );
assertEquals( 1, item1.getLevel() );
assertEquals( 1, item2.getLevel() );
assertEquals( 2, subItem1.getLevel() );
assertEquals( 2, subItem2.getLevel() );
assertEquals( 3, subSubItem1.getLevel() );
assertEquals( 3, subSubItem2.getLevel() );
Menu newRoot = new Menu();
newRoot.addItem( menu );
assertEquals( Menu.ROOT_LEVEL, newRoot.getLevel() );
assertEquals( 1, menu.getLevel() );
assertEquals( 2, item1.getLevel() );
assertEquals( 2, item2.getLevel() );
assertEquals( 3, subItem1.getLevel() );
assertEquals( 3, subItem2.getLevel() );