WorkbenchMenuStandardNavBarView extends WorkbenchMenuNavBarView { @Override public void selectMenuItem(final String id) { ComplexPanel menuItemWidget = getMenuItemWidgetMap().get(id); if (menuItemWidget == null) { menuItemWidget = GWT.create(ListItem.class); menuItemWidget.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU_EMPTY); getMenuItemWidgetMap().put(id, menuItemWidget); navbarNav.add(menuItemWidget); } super.selectMenuItem(id); addContextMenusToContainer(id, menuItemWidget); for (Map.Entry<String, ComplexPanel> context : getContextContainerWidgetMap().entrySet()) { if (context.getKey().equals(id)) { context.getValue().setVisible(true); context.getValue().getParent().addStyleName(UF_PERSPECTIVE_CONTEXT_MENU_CONTAINER); } else { context.getValue().setVisible(false); } } }  @Override void addMenuItem(final String id,
                            final String label,
                            final String parentId,
                            final Command command,
                            final MenuPosition position); @Override void addCustomMenuItem(final Widget menu,
                                  final MenuPosition position); @Override void addGroupMenuItem(final String id,
                                 final String label,
                                 final MenuPosition position); @Override void addContextMenuItem(
            final String menuItemId,
            final String id,
            final String label,
            final String parentId,
            final Command command,
            final MenuPosition position); @Override void addContextGroupMenuItem(final String menuItemId,
                                        final String id,
                                        final String label,
                                        final MenuPosition position); @Override void clearContextMenu(); @Override void selectMenuItem(final String id);  }
@Test public void testSelectMenuItemNoMenu() { final String menuId = "menuId"; when(navbarNav.iterator()).thenReturn(Collections.<Widget>emptyList().iterator()); when(listItem.getParent()).thenReturn(mock(Widget.class)); workbenchMenuStandardNavBarView.selectMenuItem(menuId); verify(navbarNav).add(listItem); }
@Test public void testSelectMenuItem() { final String menuId = "menuId"; final String label = "label"; when(navbarNav.iterator()).thenReturn(Collections.<Widget>emptyList().iterator()); when(anchorListItem.getParent()).thenReturn(mock(Widget.class)); final Widget ulParent = mock(Widget.class); when(unorderedList.getParent()).thenReturn(ulParent); workbenchMenuStandardNavBarView.addContextMenuItem(menuId, "contextMenuId", "labelContext", null, null, null); workbenchMenuStandardNavBarView.addMenuItem(menuId, label, null, null, null); workbenchMenuStandardNavBarView.selectMenuItem(menuId); verify(navbarNav).add(anchorListItem); verify(anchorListItem).setText(label); verify(unorderedList).setVisible(true); verify(ulParent).addStyleName(WorkbenchMenuNavBarView.UF_PERSPECTIVE_CONTEXT_MENU_CONTAINER); }