### Question:
MenuUtils { public static MenuItem buildItem(final IsWidget widget) { return new MenuFactory.CustomMenuBuilder() { @Override public void push(MenuFactory.CustomMenuBuilder element) { } @Override public MenuItem build() { return new BaseMenuCustom<Widget>() { @Override public Widget build() { return widget.asWidget(); } @Override public boolean isEnabled() { if (widget instanceof HasEnabledIsWidget) { return ((HasEnabledIsWidget) widget).isEnabled(); } else { return super.isEnabled(); } } @Override public void setEnabled(boolean enabled) { if (widget instanceof HasEnabledIsWidget) { ((HasEnabledIsWidget) widget).setEnabled(enabled); } else { super.setEnabled(enabled); } } }; } }.build(); }  static MenuItem buildItem(final IsWidget widget); static HasEnabledIsWidget buildHasEnabledWidget(final Button button); static HasEnabledIsWidget buildHasEnabledWidget(final ButtonGroup buttonGroup,
                                                           final Button button);  }### Answer:
@Test public void testBuildItemWithHasEnabledIsWidget() { BaseMenuCustom menuItem = (BaseMenuCustom) MenuUtils.buildItem(hasEnabledIsWidget); assertEquals(widget, menuItem.build()); menuItem.setEnabled(true); verify(hasEnabledIsWidget, times(1)).setEnabled(true); menuItem.setEnabled(false); verify(hasEnabledIsWidget, times(1)).setEnabled(false); when(hasEnabledIsWidget.isEnabled()).thenReturn(true); assertTrue(menuItem.isEnabled()); }
@Test public void testBuildItemWithNormalIsWidget() { BaseMenuCustom menuItem = (BaseMenuCustom) MenuUtils.buildItem(isWidget); assertEquals(widget, menuItem.build()); menuItem.setEnabled(true); assertTrue(menuItem.isEnabled()); menuItem.setEnabled(false); assertFalse(menuItem.isEnabled()); }