Package com.foreach.across.modules.web.menu

Examples of com.foreach.across.modules.web.menu.Menu


           .and()
           .item( "test3", "Three", "urlThree" )
           .and().and()
           .item( "test4", "Four", "urlFour" );

    Menu menu = builder.build();
    assertEquals( 4, menu.size() );

    assertEquals( "processed:One", menu.getItemWithPath( "test1" ).getTitle() );
    assertEquals( "prefixed:Two", menu.getItemWithPath( "test2" ).getTitle() );
    assertEquals( "prefixed:Three", menu.getItemWithPath( "test3" ).getTitle() );
    assertEquals( "processed:Four", menu.getItemWithPath( "test4" ).getTitle() );
  }
View Full Code Here


    assertEquals( "processed:Four", menu.getItemWithPath( "test4" ).getTitle() );
  }

  @Test
  public void buildIntoExisting() {
    Menu existing = new Menu( "one" );
    existing.addItem( "two" ).addItem( "three" );

    builder.item( "four" ).and().build( existing.getFirstItem() );

    assertEquals( "one", existing.getPath() );
    assertEquals( "two", existing.getFirstItem().getPath() );
    assertEquals( "four", existing.getFirstItem().getFirstItem().getPath() );
    assertNull( existing.getItemWithPath( "three" ) );
  }
View Full Code Here

    assertNull( existing.getItemWithPath( "three" ) );
  }

  @Test
  public void mergeIntoExisting() {
    Menu existing = new Menu( "one" );
    existing.addItem( "two" ).addItem( "three" );

    builder.item( "four" ).and().merge( existing.getFirstItem() );

    assertEquals( "one", existing.getPath() );
    assertEquals( "two", existing.getFirstItem().getPath() );
    assertEquals( "three", existing.getFirstItem().getFirstItem().getPath() );
    assertEquals( "four", existing.getFirstItem().getItems().get( 1 ).getPath() );
  }
View Full Code Here

    processor = new PrefixContextMenuItemBuilderProcessor( new PrefixingPathContext( "/test" ) );
  }

  @Test
  public void processMenuWithoutUrl() {
    Menu menu = new Menu( "path" );

    assertFalse( menu.hasUrl() );

    Menu processed = processor.process( menu );

    assertSame( menu, processed );
    assertEquals( "path", menu.getPath() );
    assertTrue( menu.hasUrl() );
    assertEquals( "/test/path", menu.getUrl() );
View Full Code Here

    assertTrue( matchers.contains( "/test/path" ) );
  }

  @Test
  public void processGroupShouldNotTouchUrl() {
    Menu menu = new Menu( "path" );
    menu.setGroup( true );

    assertFalse( menu.hasUrl() );

    Menu processed = processor.process( menu );

    assertSame( menu, processed );
    assertEquals( "path", menu.getPath() );
    assertFalse( menu.hasUrl() );
View Full Code Here

    assertTrue( matchers.contains( "/test/path" ) );
  }

  @Test
  public void processMenuWithUrl() {
    Menu menu = new Menu( "/second" );
    menu.setUrl( "/my/url" );
    menu.setAttribute( RequestMenuSelector.ATTRIBUTE_MATCHERS, Arrays.asList( "one", "two" ) );

    Menu processed = processor.process( menu );

    assertSame( menu, processed );
    assertEquals( "/second", menu.getPath() );
    assertEquals( "/test/my/url", menu.getUrl() );
View Full Code Here

    }
  };

  @Test
  public void singleLevelSorting() {
    Menu menu = new Menu( "any" );
    menu.addItem( "/aaa", "ccc" );
    menu.addItem( "/bbb", "aaa" );
    menu.addItem( "/ccc", "bbb" );

    menu.sort();

    assertMenu( menu, "aaa", "bbb", "ccc" );
  }
View Full Code Here

    assertMenu( menu, "aaa", "bbb", "ccc" );
  }

  @Test
  public void multiLevelSorting() {
    Menu menu = new Menu( "any" );

    Menu subMenu = new Menu( "/aaa", "ccc" );
    subMenu.addItem( "111", "333" );
    subMenu.addItem( "222", "222" );
    subMenu.addItem( "333", "111" );
    menu.addItem( subMenu );

    menu.addItem( "/bbb", "aaa" );

    Menu otherSubMenu = new Menu( "/ccc", "bbb" );
    otherSubMenu.addItem( "111", "111" );
    otherSubMenu.addItem( "222", "333" );
    otherSubMenu.addItem( "333", "222" );
    menu.addItem( otherSubMenu );

    menu.sort();

    assertMenu( menu, "aaa", "bbb", "ccc" );
View Full Code Here

    assertMenu( menu.getItems().get( 2 ), "111", "222", "333" );
  }

  @Test
  public void multiLevelSortingWithOrderValues() {
    Menu menu = new Menu( "any" );

    Menu subMenu = new Menu( "/aaa", "ccc" );
    subMenu.addItem( "111", "333" ).setOrder( Ordered.HIGHEST_PRECEDENCE );
    subMenu.addItem( "222", "222" );
    subMenu.addItem( "333", "111" ).setOrder( Ordered.LOWEST_PRECEDENCE );
    menu.addItem( subMenu );

    menu.addItem( "/bbb", "aaa" );

    Menu otherSubMenu = new Menu( "/ccc", "bbb" );
    otherSubMenu.addItem( "111", "111" );
    otherSubMenu.addItem( "222", "333" );
    otherSubMenu.addItem( "333", "222" ).setOrder( 1 );
    menu.addItem( otherSubMenu );

    menu.sort();

    assertMenu( menu, "aaa", "bbb", "ccc" );
View Full Code Here

    assertMenu( menu.getItems().get( 2 ), "333", "222", "111" );
  }

  @Test
  public void orderedMenuIsNotSorted() {
    Menu menu = new Menu( "any" );
    menu.setOrdered( true );
    menu.addItem( "/aaa", "ccc" );
    menu.addItem( "/bbb", "aaa" );
    menu.addItem( "/ccc", "bbb" );

    menu.sort();

    assertMenu( menu, "ccc", "aaa", "bbb" );
  }
View Full Code Here

TOP

Related Classes of com.foreach.across.modules.web.menu.Menu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.