Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.uberfire.workbench.model.menu.impl;
  
  import org.junit.Test;
 
 import static org.fest.assertions.api.Assertions.*;
 import static org.uberfire.workbench.model.menu.MenuFactory.*;

 
 public class TestBehavior {
 
     private static Command DUMMY = new Command(){
         @Override
         public void execute(){
 
         }
     };
 
     @Test
     public void testSimpleMenu() {
         final Menus menus = newTopLevelMenu"File" )
                         .position. )
                         .menus()
                             .menu"Save" )
                                .order( 2 )
                                .respondsWith )
                             .endMenu()
                             .menu"Close" )
                                 .respondsWith )
                             .endMenu()
                         .endMenus()
                     .endMenu().build();
 
         final Menus custom = newTopLevelMenu"X" )
                 .customnew CustomMenuBuilder() {
                     @Override
                     public void pushCustomMenuBuilder element ) {
                     }
 
                     @Override
                     public MenuItem build() {
                         return null;
                     }
                 } )
                 .endMenu().build();
 
         assertThatmenus ).isNotNull();
         assertThatmenus.getItems() ).isNotNull().hasSize( 1 );
         assertThatmenus.getItems().get( 0 ) ).isNotNull();
         assertThatmenus.getItems().get( 0 ) ).isInstanceOfMenuGroup.class );
         assertThatmenus.getItems().get( 0 ).getPosition() ).isEqualTo. );
         assertThatmenus.getItems().get( 0 ).getCaption() ).isEqualTo"File" );
         assertThat( ((MenuGroupmenus.getItems().get( 0 )).getItems() ).hasSize( 2 );
 
         {
             final MenuItem menuItem = ((MenuGroupmenus.getItems().get( 0 )).getItems().get( 0 );
             assertThatmenuItem ).isNotNull();
             assertThatmenuItem.getCaption() ).isEqualTo"Save" );
             assertThatmenuItem.getOrder() ).isEqualTo( 2 );
         }
         {
             final MenuItem menuItem = ((MenuGroupmenus.getItems().get( 0 )).getItems().get( 1 );
             assertThatmenuItem ).isNotNull();
             assertThatmenuItem.getCaption() ).isEqualTo"Close" );
         }
     }
 
     @Test
     public void testSimpleNestedMenu() {
         final Menus menus = newTopLevelMenu"File" )
                         .menus()
                             .menu"Operations" )
                                 .menus()
                                     .menu"Save" )
                                         .respondsWith )
                                     .endMenu()
                                     .menu"Close" )
                                         .respondsWith )
                                     .endMenu()
                                 .endMenus()
                             .endMenu()
                         .endMenus()
                     .endMenu()
                     .newTopLevelMenu"Explore" )
                         .respondsWith )
                     .endMenu()
                     .build();
 
         assertThatmenus ).isNotNull();
         assertThatmenus.getItems() ).isNotNull().hasSize( 2 );
        {
            assertThatmenus.getItems().get( 0 ) ).isNotNull();
            assertThatmenus.getItems().get( 0 ) ).isInstanceOfMenuGroup.class );
            assertThatmenus.getItems().get( 0 ).getCaption() ).isEqualTo"File" );
            assertThat( ((MenuGroupmenus.getItems().get( 0 )).getItems() ).hasSize( 1 );
            {
                final MenuItem menuItem = ((MenuGroupmenus.getItems().get( 0 )).getItems().get( 0 );
                assertThatmenuItem ).isNotNull();
                assertThatmenuItem.getCaption() ).isEqualTo"Operations" );
                assertThatmenuItem ).isInstanceOfMenuGroup.class );
                {
                    final MenuItem subMenuItem = ((MenuGroupmenuItem).getItems().get( 0 );
                    assertThatsubMenuItem ).isNotNull();
                    assertThatsubMenuItem.getCaption() ).isEqualTo"Save" );
                }
                {
                    final MenuItem subMenuItem = ((MenuGroupmenuItem).getItems().get( 1 );
                    assertThatsubMenuItem ).isNotNull();
                    assertThatsubMenuItem.getCaption() ).isEqualTo"Close" );
                }
            }
            assertThatmenus.getItems().get( 1 ) ).isNotNull();
            assertThatmenus.getItems().get( 1 ) ).isInstanceOfMenuItemCommand.class );
            assertThatmenus.getItems().get( 1 ).getCaption() ).isEqualTo"Explore" );
        }
    }
New to GrepCode? Check out our FAQ X