ColumnsPagePresenter { boolean isColumnCreationEnabled(final Optional<GuidedDecisionTableView.Presenter> dtPresenter) { if (!dtPresenter.isPresent()) { return false; } final GuidedDecisionTableView.Presenter dt = dtPresenter.get(); final boolean decisionTableIsEditable = !dt.isReadOnly(); final boolean decisionTableHasEditableColumns = dt.hasEditableColumns(); return decisionTableHasEditableColumns && decisionTableIsEditable; } @Inject  ColumnsPagePresenter(final View view,
                                final GuidedDecisionTableAccordion accordion,
                                final ManagedInstance<NewGuidedDecisionTableColumnWizard> wizardManagedInstance,
                                final TranslationService translationService,
                                final ManagedInstance<DeleteColumnManagementAnchorWidget> deleteColumnManagementAnchorWidgets,
                                final ManagedInstance<AttributeColumnConfigRow> attributeColumnConfigRow,
                                final ColumnManagementView conditionsPanel,
                                final ColumnManagementView actionsPanel,
                                final ShowRuleNameOptionPresenter showRuleNameOptionPresenter); @PostConstruct void setup(); View getView(); void init(final GuidedDecisionTableModellerView.Presenter modeller); void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event); void onRefreshAttributesPanelEvent(final @Observes RefreshAttributesPanelEvent event); void onRefreshMetaDataPanelEvent(final @Observes RefreshMetaDataPanelEvent event); void onRefreshConditionsPanelEvent(final @Observes RefreshConditionsPanelEvent event); void onRefreshActionsPanelEvent(final @Observes RefreshActionsPanelEvent event); GuidedDecisionTableAccordion getAccordion(); void onDecisionTableSelected(final @Observes DecisionTableSelectedEvent event); void refresh();  }
@Test public void testIsColumnCreationEnabledWhenActiveDecisionTableIsReadOnly() { final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class); doReturn(true).when(dtPresenter).isReadOnly(); final boolean isColumnCreationEnabled = presenter.isColumnCreationEnabled(Optional.of(dtPresenter)); assertFalse(isColumnCreationEnabled); }
@Test public void testIsColumnCreationEnabledWhenActiveDecisionTableDoesNotHaveEditableColumns() { final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class); doReturn(false).when(dtPresenter).isReadOnly(); doReturn(false).when(dtPresenter).hasEditableColumns(); final boolean isColumnCreationEnabled = presenter.isColumnCreationEnabled(Optional.of(dtPresenter)); assertFalse(isColumnCreationEnabled); }
@Test public void testIsColumnCreationEnabledWhenActiveDecisionTableHasEditableColumns() { final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class); doReturn(false).when(dtPresenter).isReadOnly(); doReturn(true).when(dtPresenter).hasEditableColumns(); final boolean isColumnCreationEnabled = presenter.isColumnCreationEnabled(Optional.of(dtPresenter)); assertTrue(isColumnCreationEnabled); }