MenuItemFactory { @SuppressWarnings("unchecked") public <T extends MenuItemDividerView> MenuItemViewHolder<T> makeMenuItemDivider() { final MenuItemView _view = menuItemViewProducer.select(new MenuItemDivider() { @Override public Class<? extends Annotation> annotationType() { return MenuItemDivider.class; } }).get(); final T view = (T) _view; final MenuItem item = MenuFactory.newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() { @Override public void push(final MenuFactory.CustomMenuBuilder element) { } @Override public MenuItem build() { final BaseMenuCustom<IsWidget> cmdItem = new BaseMenuCustom<IsWidget>() { @Override public IsWidget build() { return ElementWrapperWidget.getWidget(view.getElement()); } }; return cmdItem; } }).endMenu().build().getItems().get(0); return new MenuItemViewHolder<>(item, view); } @Inject  MenuItemFactory(final @Any ManagedInstance<MenuItemView> menuItemViewProducer); @SuppressWarnings("unchecked") MenuItemViewHolder<T> makeMenuItemWithIcon(final String caption,
                                                                                       final Command cmd); @SuppressWarnings("unchecked") MenuItemViewHolder<T> makeMenuItemHeader(final String caption); @SuppressWarnings("unchecked") MenuItemViewHolder<T> makeMenuItemDivider();  }
@Test public void checkMenuItemDividerConstruction() { final MenuItemViewHolder<MenuItemDividerView> mih = menuItemFactory.makeMenuItemDivider(); assertNotNull(mih); assertNotNull(mih.getMenuItem()); assertNotNull(mih.getMenuItemView()); }