WorkbenchMegaMenuPresenter extends WorkbenchBaseMenuPresenter { void setup() { view.init(this); setupBrand(); setupHomeLink(); } WorkbenchMegaMenuPresenter(final AuthorizationManager authzManager,
                                      final PerspectiveManager perspectiveManager,
                                      final ActivityManager activityManager,
                                      final User identity,
                                      final View view,
                                      final ManagedInstance<MegaMenuBrand> megaMenuBrands,
                                      final PlaceManager placeManager,
                                      final AuthorizationManager authorizationManager,
                                      final SessionInfo sessionInfo,
                                      final ManagedInstance<ChildMenuItemPresenter> childMenuItemPresenters,
                                      final ManagedInstance<GroupMenuItemPresenter> groupMenuItemPresenters,
                                      final ManagedInstance<ChildContextMenuItemPresenter> childContextMenuItemPresenters,
                                      final ManagedInstance<GroupContextMenuItemPresenter> groupContextMenuItemPresenters,
                                      final Workbench workbench,
                                      final ExperimentalActivitiesAuthorizationManager experimentalActivitiesAuthorizationManager); IsElement getView(); void clear(); void addMenuItem(final String id,
                            final String label,
                            final String parentId,
                            final Command command,
                            final MenuPosition position); void addCustomMenuItem(final IsElement menu,
                                  final MenuPosition position); void addCustomMenuItem(IsWidget menu,
                                  MenuPosition position); void addGroupMenuItem(final String id,
                                 final String label,
                                 final MenuPosition position); void selectMenuItem(final String id); void addContextMenuItem(final String menuItemId,
                                   final String id,
                                   final String label,
                                   final String parentId,
                                   final Command command,
                                   final MenuPosition position); void addContextGroupMenuItem(final String menuItemId,
                                        final String id,
                                        final String label,
                                        final MenuPosition position); void clearContextMenu(); void enableMenuItem(final String menuItemId,
                               final boolean enabled); void enableContextMenuItem(final String menuItemId,
                                      final boolean enabled); void onPerspectiveChange(final PerspectiveChange perspectiveChange); void setupSetVisibleMenuItem(MenuItemPerspective menuItemPerspective);  }
@Test(expected = RuntimeException.class) public void setupWithMoreThanOneMegaMenuBrandImplementationTest() { doReturn(true).when(megaMenuBrands).isAmbiguous(); presenter.setup(); }
@Test public void setupWithNoMegaMenuBrandImplementationTest() { doReturn(true).when(megaMenuBrands).isUnsatisfied(); presenter.setup(); verify(view).hideBrand(); }
@Test public void setupWithOneEmptyMegaMenuBrandImplementationTest() { doReturn(false).when(megaMenuBrands).isAmbiguous(); doReturn(false).when(megaMenuBrands).isUnsatisfied(); final MegaMenuBrandMock megaMenuBrand = new MegaMenuBrandMock("", "", ""); doReturn(megaMenuBrand).when(megaMenuBrands).get(); doReturn("defaultMenuText").when(view).getDefaultMenuText(); presenter.setup(); verify(view, never()).setBrandImage(anyString()); verify(view, never()).setBrandImageTitle(anyString()); verify(view).hideBrand(); verify(view).setMenuAccessorText(view.getDefaultMenuText()); }
@Test public void setupWithOneMegaMenuBrandImplementationTest() { doReturn(false).when(megaMenuBrands).isAmbiguous(); doReturn(false).when(megaMenuBrands).isUnsatisfied(); final MegaMenuBrandMock megaMenuBrand = new MegaMenuBrandMock("brandImageUrl", "brandImageLabel", "menuAccessorLabel"); doReturn(megaMenuBrand).when(megaMenuBrands).get(); doReturn("defaultMenuText").when(view).getDefaultMenuText(); presenter.setup(); verify(view).setBrandImage(megaMenuBrand.brandImageUrl()); verify(view).setBrandImageTitle(megaMenuBrand.brandImageLabel()); verify(view, never()).hideBrand(); verify(view).setMenuAccessorText(megaMenuBrand.menuAccessorLabel()); }