ViewMenuBuilder extends BaseMenu implements MenuFactory.CustomMenuBuilder { public void onDecisionTablePinnedEvent(final @Observes DecisionTablePinnedEvent event) { final GuidedDecisionTableModellerView.Presenter modeller = event.getPresenter(); if (modeller == null) { return; } if (!modeller.equals(this.modeller)) { return; } enableZoomMenu(!event.isPinned()); } @Inject  ViewMenuBuilder(final TranslationService ts,
                           final MenuItemFactory menuItemFactory); @PostConstruct void setup(); void setModeller(final GuidedDecisionTableModellerView.Presenter modeller); @Override void push(final MenuFactory.CustomMenuBuilder element); @Override MenuItem build(); @Override void onDecisionTableSelectedEvent(final @Observes DecisionTableSelectedEvent event); @Override void onRefreshMenusEvent(final @Observes RefreshMenusEvent event); @Override void initialise(); void onDecisionTablePinnedEvent(final @Observes DecisionTablePinnedEvent event);  }
@Test public void testEnableZoom_Pinned() { builder.onDecisionTablePinnedEvent(new DecisionTablePinnedEvent(modeller, true)); assertFalse(builder.miZoom125pct.getMenuItem().isEnabled()); assertFalse(builder.miZoom100pct.getMenuItem().isEnabled()); assertFalse(builder.miZoom75pct.getMenuItem().isEnabled()); assertFalse(builder.miZoom50pct.getMenuItem().isEnabled()); }
@Test public void testEnableZoom_Pinned_DifferentModeller() { builder.onDecisionTablePinnedEvent(new DecisionTablePinnedEvent(mock(GuidedDecisionTableModellerView.Presenter.class), true)); verify(builder.miZoom125pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom100pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom75pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom50pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); }
@Test public void testEnableZoom_Unpinned() { builder.onDecisionTablePinnedEvent(new DecisionTablePinnedEvent(modeller, false)); verify(builder.miZoom125pct.getMenuItemView(), times(1)).setEnabled(eq(true)); verify(builder.miZoom100pct.getMenuItemView(), times(1)).setEnabled(eq(true)); verify(builder.miZoom75pct.getMenuItemView(), times(1)).setEnabled(eq(true)); verify(builder.miZoom50pct.getMenuItemView(), times(1)).setEnabled(eq(true)); }
@Test public void testEnableZoom_Unpinned_DifferentModeller() { builder.onDecisionTablePinnedEvent(new DecisionTablePinnedEvent(mock(GuidedDecisionTableModellerView.Presenter.class), false)); verify(builder.miZoom125pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom100pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom75pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); verify(builder.miZoom50pct.getMenuItemView(), never()).setEnabled(any(Boolean.class)); }