Search in sources :

Example 51 with ActionCol52

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

the class BaseColumnSynchronizer method findTargetActionIndex.

protected int findTargetActionIndex(final MoveColumnToMetaData md) throws ModelSynchronizer.MoveVetoException {
    int tgtActionIndex = -1;
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final List<ActionCol52> allModelActions = model.getActionCols();
    for (int actionIndex = 0; actionIndex < allModelActions.size(); actionIndex++) {
        final ActionCol52 ac = allModelActions.get(actionIndex);
        final List<ActionCol52> children = getChildren(ac);
        if (children == null || children.isEmpty()) {
            continue;
        }
        final BaseColumn firstChild = children.get(0);
        final BaseColumn lastChild = children.get(children.size() - 1);
        final int firstChildIndex = allModelColumns.indexOf(firstChild);
        final int lastChildIndex = allModelColumns.indexOf(lastChild);
        if (tgtColumnIndex >= firstChildIndex && tgtColumnIndex <= lastChildIndex) {
            tgtActionIndex = actionIndex;
            break;
        }
    }
    if (tgtActionIndex < 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    return tgtActionIndex;
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 52 with ActionCol52

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

the class DecisionTableColumnViewUtilsTest method testColumnManagementGroupTitle.

@Test
public void testColumnManagementGroupTitle() throws Exception {
    final ActionCol52 column = mock(ActionCol52.class);
    doReturn(COLUMN_HEADER).when(column).getHeader();
    assertEquals(COLUMN_HEADER, DecisionTableColumnViewUtils.getColumnManagementGroupTitle(column));
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Test(org.junit.Test)

Example 53 with ActionCol52

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

the class ActionSetFactPluginTest method testGenerateColumnWhenColumnIsNew.

@Test
public void testGenerateColumnWhenColumnIsNew() throws Exception {
    final ActionCol52 actionCol52 = mock(ActionCol52.class);
    doReturn(actionCol52).when(plugin).editingCol();
    doReturn(true).when(plugin).isNewColumn();
    assertTrue(plugin.generateColumn());
    verify(presenter).appendColumn(actionCol52);
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Test(org.junit.Test)

Example 54 with ActionCol52

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

the class ActionWorkItemPluginTest method testGetAlreadyUsedColumnNames.

@Test
public void testGetAlreadyUsedColumnNames() throws Exception {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    model.getActionCols().add(new ActionCol52() {

        {
            setHeader("a");
        }
    });
    model.getActionCols().add(new ActionCol52() {

        {
            setHeader("b");
        }
    });
    when(presenter.getModel()).thenReturn(model);
    assertEquals(2, plugin.getAlreadyUsedColumnHeaders().size());
    assertTrue(plugin.getAlreadyUsedColumnHeaders().contains("a"));
    assertTrue(plugin.getAlreadyUsedColumnHeaders().contains("b"));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Test(org.junit.Test)

Example 55 with ActionCol52

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

the class ActionWorkItemSetFieldPluginTest method testGenerateColumnWhenColumnIsNotNew.

@Test
public void testGenerateColumnWhenColumnIsNotNew() throws Exception {
    final ActionCol52 editingColumn = mock(ActionCol52.class);
    final ActionCol52 originalColumn = mock(ActionCol52.class);
    final String header = "header";
    doReturn(false).when(plugin).isNewColumn();
    doReturn(header).when(editingWrapper).getHeader();
    doReturn("factField").when(editingWrapper).getFactField();
    doReturn("factType2").when(editingWrapper).getFactType();
    doReturn(editingWrapper).when(plugin).editingWrapper();
    doReturn(editingColumn).when(editingWrapper).getActionCol52();
    doReturn(originalColumn).when(plugin).getOriginalColumnConfig52();
    final Boolean success = plugin.generateColumn();
    assertTrue(success);
    verify(presenter).updateColumn(originalColumn, editingColumn);
    verify(translationService, never()).format(any());
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Aggregations

ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)60 Test (org.junit.Test)31 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 ArrayList (java.util.ArrayList)17 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)16 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)13 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)13 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)12 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)11 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)10 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)9 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)8 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)8 List (java.util.List)6 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)6 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)6 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)6