Search in sources :

Example 51 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.

the class PluginHandlerTest method testEditWhenColumnIsABRLActionColumn.

@Test
public void testEditWhenColumnIsABRLActionColumn() {
    final BRLActionColumn originalColumn = mock(BRLActionColumn.class);
    final BRLActionColumnPlugin plugin = spy(new BRLActionColumnPlugin(ruleModellerPage, new MockInstanceImpl<>(new ArrayList<>()), additionalInfoPage, event, translationService));
    testEditActionColumn(plugin, brlActionColumnPlugin, originalColumn);
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BRLActionColumnPlugin(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.BRLActionColumnPlugin) MockInstanceImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.MockInstanceImpl) Test(org.junit.Test)

Example 52 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.

the class ColumnManagementViewTest method testRenderColumnActionsNotEditable.

@Test
public void testRenderColumnActionsNotEditable() throws Exception {
    final BRLActionColumn brlActionColumn = mock(BRLActionColumn.class);
    final ActionInsertFactCol52 actionInsertFactColumn = mock(ActionInsertFactCol52.class);
    final ActionRetractFactCol52 retractFactColumn = mock(ActionRetractFactCol52.class);
    final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {

        {
            put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(brlActionColumn, actionInsertFactColumn, retractFactColumn));
        }
    };
    final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
    doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
    view.renderColumns(columnGroups);
    verify(view).renderColumn(brlActionColumn);
    verify(view).renderColumn(actionInsertFactColumn);
    verify(view).renderColumn(retractFactColumn);
    // There are three action columns
    verify(horizontalPanel, times(3)).add(columnLabel);
    verify(view, times(3)).editAnchor(any(ClickHandler.class));
    verify(view, never()).deleteAnchor(eq("one"), any(Command.class));
    verify(view, never()).deleteAnchor(eq("two"), any(Command.class));
    verify(view, never()).deleteAnchor(eq("three"), any(Command.class));
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) HashMap(java.util.HashMap) Command(com.google.gwt.user.client.Command) List(java.util.List) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 53 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.

the class ColumnManagementViewTest method testRenderColumnActionsEditable.

@Test
public void testRenderColumnActionsEditable() throws Exception {
    final BRLActionColumn brlActionColumn = mock(BRLActionColumn.class);
    final ActionInsertFactCol52 actionInsertFactColumn = mock(ActionInsertFactCol52.class);
    final ActionRetractFactCol52 retractFactColumn = mock(ActionRetractFactCol52.class);
    final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {

        {
            put(GuidedDecisionTableConstants.INSTANCE.BrlConditions(), Arrays.asList(brlActionColumn, actionInsertFactColumn, retractFactColumn));
        }
    };
    final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
    doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
    doReturn(true).when(modellerPresenter).isActiveDecisionTableEditable();
    doReturn("one").when(brlActionColumn).getHeader();
    doReturn("two").when(actionInsertFactColumn).getHeader();
    doReturn("three").when(retractFactColumn).getHeader();
    view.renderColumns(columnGroups);
    verify(view).renderColumn(brlActionColumn);
    verify(view).renderColumn(actionInsertFactColumn);
    verify(view).renderColumn(retractFactColumn);
    // There are three action columns
    verify(horizontalPanel, times(3)).add(columnLabel);
    verify(view, times(3)).editAnchor(clickHandlerCaptor.capture());
    verify(view).deleteAnchor(eq("one"), deleteCommandCaptor.capture());
    verify(view).deleteAnchor(eq("two"), deleteCommandCaptor.capture());
    verify(view).deleteAnchor(eq("three"), deleteCommandCaptor.capture());
    clickHandlerCaptor.getAllValues().get(0).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editAction(eq(brlActionColumn));
    clickHandlerCaptor.getAllValues().get(1).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editAction(eq(actionInsertFactColumn));
    clickHandlerCaptor.getAllValues().get(2).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editAction(eq(retractFactColumn));
    deleteCommandCaptor.getAllValues().get(0).execute();
    verify(decisionTablePresenter).deleteColumn(brlActionColumn);
    deleteCommandCaptor.getAllValues().get(1).execute();
    verify(decisionTablePresenter).deleteColumn(actionInsertFactColumn);
    deleteCommandCaptor.getAllValues().get(2).execute();
    verify(decisionTablePresenter).deleteColumn(retractFactColumn);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) List(java.util.List) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 54 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.

the class BRLActionColumnSynchronizer method doMoveBRLFragment.

private void doMoveBRLFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final BRLActionVariableColumn srcModelColumn = (BRLActionVariableColumn) md.getColumn();
    final BRLActionColumn srcModelBRLFragment = model.getBRLColumn(srcModelColumn);
    if (srcModelBRLFragment == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BRLActionVariableColumn> srcModelBRLFragmentColumns = srcModelBRLFragment.getChildColumns();
    final int srcModelBRLFragmentColumnsCount = srcModelBRLFragmentColumns.size();
    if (srcModelBRLFragmentColumnsCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelBRLFragmentColumnsCount != metaData.size()) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final int tgtActionIndex = findTargetActionIndex(md);
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)), allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)) + srcModelBRLFragmentColumnsCount - 1);
    model.getActionCols().remove(srcModelBRLFragment);
    model.getActionCols().add(tgtActionIndex, srcModelBRLFragment);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 55 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.

the class BRLActionColumnSynchronizer method append.

@Override
public void append(final ColumnMetaData metaData) throws VetoException {
    // Check operation is supported
    if (!handlesAppend(metaData)) {
        return;
    }
    final BRLActionColumn column = (BRLActionColumn) metaData.getColumn();
    model.getActionCols().add(column);
    for (BRLActionVariableColumn childModelColumn : column.getChildColumns()) {
        synchroniseAppendColumn(childModelColumn);
    }
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Aggregations

BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)71 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)51 Test (org.junit.Test)51 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)31 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)24 ArrayList (java.util.ArrayList)21 IAction (org.drools.workbench.models.datamodel.rule.IAction)21 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)19 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)19 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)18 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)16 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)16 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)15 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)15 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)13 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)13 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)13 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)11 IOException (java.io.IOException)9