InsertMenuBuilder extends BaseMenu implements MenuFactory.CustomMenuBuilder { @Override public void onDecisionTableSelectionsChangedEvent(final @Observes DecisionTableSelectionsChangedEvent event) { super.onDecisionTableSelectionsChangedEvent(event); } @Inject  InsertMenuBuilder(final TranslationService ts,
                             final MenuItemFactory menuItemFactory,
                             final ManagedInstance<NewGuidedDecisionTableColumnWizard> wizardManagedInstance); @PostConstruct void setup(); @Override void push(final MenuFactory.CustomMenuBuilder element); @Override MenuItem build(); @Override void onDecisionTableSelectedEvent(final @Observes DecisionTableSelectedEvent event); @Override void onDecisionTableSelectionsChangedEvent(final @Observes DecisionTableSelectionsChangedEvent event); @Override void onRefreshMenusEvent(final @Observes RefreshMenusEvent event); @Override void initialise(); void setModeller(final GuidedDecisionTableModellerView.Presenter modeller);  }
@Test public void testOnDecisionTableSelectionsChangedEventWithNoSelectionsAndItHasEditableColumns() { builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertTrue(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithNoSelectionsAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertFalse(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithSingleRowSelectedAndItHasEditableColumns() { model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52List()); uiModel.selectCell(0, 2); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertTrue(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertTrue(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertTrue(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithSingleRowSelectedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52List()); uiModel.selectCell(0, 2); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertTrue(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertTrue(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertFalse(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithMultipleRowsSelectedAndItHasEditableColumns() { model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52List()); model.getData().add(makeDTCellValue52List()); uiModel.selectCells(0, 2, 1, 2); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertTrue(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithMultipleRowsSelectedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52List()); model.getData().add(makeDTCellValue52List()); uiModel.selectCells(0, 2, 1, 2); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertFalse(builder.miInsertColumn.getMenuItem().isEnabled()); }