}
}
@Test
public void testSimpleNestedMenu() {
final Menus menus = newTopLevelMenu( "File" )
.menus()
.menu( "Operations" )
.menus()
.menu( "Save" )
.respondsWith( DUMMY )
.endMenu()
.menu( "Close" )
.respondsWith( DUMMY )
.endMenu()
.endMenus()
.endMenu()
.endMenus()
.endMenu()
.newTopLevelMenu( "Explore" )
.respondsWith( DUMMY )
.endMenu()
.build();
assertThat( menus ).isNotNull();
assertThat( menus.getItems() ).isNotNull().hasSize( 2 );
{
assertThat( menus.getItems().get( 0 ) ).isNotNull();
assertThat( menus.getItems().get( 0 ) ).isInstanceOf( MenuGroup.class );
assertThat( menus.getItems().get( 0 ).getCaption() ).isEqualTo( "File" );
assertThat( ((MenuGroup) menus.getItems().get( 0 )).getItems() ).hasSize( 1 );
{
final MenuItem menuItem = ((MenuGroup) menus.getItems().get( 0 )).getItems().get( 0 );
assertThat( menuItem ).isNotNull();
assertThat( menuItem.getCaption() ).isEqualTo( "Operations" );
assertThat( menuItem ).isInstanceOf( MenuGroup.class );
{
final MenuItem subMenuItem = ((MenuGroup) menuItem).getItems().get( 0 );
assertThat( subMenuItem ).isNotNull();
assertThat( subMenuItem.getCaption() ).isEqualTo( "Save" );
}
{
final MenuItem subMenuItem = ((MenuGroup) menuItem).getItems().get( 1 );
assertThat( subMenuItem ).isNotNull();
assertThat( subMenuItem.getCaption() ).isEqualTo( "Close" );
}
}
assertThat( menus.getItems().get( 1 ) ).isNotNull();
assertThat( menus.getItems().get( 1 ) ).isInstanceOf( MenuItemCommand.class );
assertThat( menus.getItems().get( 1 ).getCaption() ).isEqualTo( "Explore" );
}
}