### Question:
NewResourcesMenu implements WorkspaceProjectContextChangeHandler { public List<MenuItem> getMenuItems() { enableMenuItemsForContext(); return items; } NewResourcesMenu(); @Inject  NewResourcesMenu( final SyncBeanManager iocBeanManager,
                             final NewResourcePresenter newResourcePresenter,
                             final WorkspaceProjectContext projectContext ); @PostConstruct void setup(); List<MenuItem> getMenuItems(); List<MenuItem> getMenuItemsWithoutProject(); @Override void onChange(WorkspaceProjectContextChangeEvent previous, WorkspaceProjectContextChangeEvent current);  }### Answer:
@Test public void testGetMenuItems() { final List<MenuItem> menus = menu.getMenuItems(); assertNotNull( menus ); assertEquals( 1, menus.size() ); }
@Test public void testGetMenuItemsCanNotCreate() { when( handler.canCreate() ).thenReturn( false ); final List<MenuItem> menus = menu.getMenuItems(); assertNotNull( menus ); assertEquals( 1, menus.size() ); }
@Test public void testMenuItemCommand() { final List<MenuItem> menus = menu.getMenuItems(); assertNotNull( menus ); assertEquals( 1, menus.size() ); final MenuItem mi = menus.get( 0 ); assertTrue( mi.isEnabled() ); assertTrue( mi instanceof MenuItemCommand ); final MenuItemCommand miu = (MenuItemCommand) mi; assertNotNull( miu.getCommand() ); miu.getCommand().execute(); verify( command, times( 1 ) ).execute(); }
@Test @SuppressWarnings("unchecked") public void getMenuItemsSynchronizesEnabledState() { menu.getMenuItems(); verify( handler, times( 1 ) ).acceptContext( any( Callback.class ) ); }