Search in sources :

Example 56 with ActionCol52

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

the class ActionWorkItemSetFieldPluginTest method mockPatterns.

private void mockPatterns() {
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final List<CompositeColumn<?>> patterns = Collections.singletonList(fakePattern());
    final List<ActionCol52> actions = Arrays.asList(fakeActionCol(), fakeActionCol());
    when(model.getConditions()).thenReturn(patterns);
    when(model.getActionCols()).thenReturn(actions);
    when(presenter.getModel()).thenReturn(model);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 57 with ActionCol52

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

the class BRLActionColumnPluginTest method testGenerateColumnWhenColumnIsNew.

@Test
public void testGenerateColumnWhenColumnIsNew() throws Exception {
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final ArrayList<ActionCol52> actionCol52s = new ArrayList<>();
    when(model.getActionCols()).thenReturn(actionCol52s);
    when(presenter.getModel()).thenReturn(model);
    when(editingCol.getHeader()).thenReturn("header");
    when(plugin.isNewColumn()).thenReturn(true);
    final Boolean success = plugin.generateColumn();
    assertTrue(success);
    verify(plugin).getDefinedVariables(any());
    verify(editingCol).setDefinition(any());
    verify(presenter).appendColumn(editingCol);
    verify(translationService, never()).format(any());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) Mockito.anyBoolean(org.mockito.Mockito.anyBoolean) Test(org.junit.Test)

Example 58 with ActionCol52

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

the class ConditionColumnSynchronizerTest method checkConditionCannotBeUpdatedWhenBindingIsUsedInAction.

@Test
public void checkConditionCannotBeUpdatedWhenBindingIsUsedInAction() throws VetoException {
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition = ageEqualsCondition();
    final ActionCol52 action = actionUpdatePattern("$a");
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendColumn(action);
    try {
        final Pattern52 editedPattern = boundApplicantPattern("$a2");
        final ConditionCol52 editedCondition = nameEqualsCondition();
        modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
        fail("Update of the column should have been vetoed.");
    } catch (VetoUpdatePatternInUseException veto) {
    // This is expected
    } catch (VetoException veto) {
        fail("VetoUpdatePatternInUseException was expected.");
    }
    assertEquals(4, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
    assertEquals(condition, model.getExpandedColumns().get(2));
    assertEquals(action, model.getExpandedColumns().get(3));
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) VetoUpdatePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 59 with ActionCol52

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

the class ConditionColumnSynchronizerTest method checkConditionCannotBeDeletedWithSingleChildColumnWithAction.

@Test
public void checkConditionCannotBeDeletedWithSingleChildColumnWithAction() throws VetoException {
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition = ageEqualsCondition();
    final ActionCol52 action = actionUpdatePattern("$a");
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendColumn(action);
    try {
        modelSynchronizer.deleteColumn(condition);
        fail("Deletion of the column should have been vetoed.");
    } catch (VetoDeletePatternInUseException veto) {
    // This is expected
    } catch (VetoException veto) {
        fail("VetoDeletePatternInUseException was expected.");
    }
    assertEquals(4, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
    assertEquals(condition, model.getExpandedColumns().get(2));
    assertEquals(action, model.getExpandedColumns().get(3));
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) VetoDeletePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoDeletePatternInUseException) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 60 with ActionCol52

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

the class CellBuilder method build.

public void build() throws BuildException {
    if (baseColumn instanceof ActionCol52) {
        final Action action = builderFactory.getActionBuilder().with(rule).with(row).with(columnIndex).with((ActionCol52) baseColumn).build();
        rule.getActions().add(action);
    } else if (baseColumn instanceof ConditionCol52) {
        if (baseColumn instanceof BRLConditionVariableColumn) {
            final Condition condition = builderFactory.getBRLConditionBuilder().with((BRLConditionVariableColumn) baseColumn).with(getRealCellValue((BRLConditionVariableColumn) baseColumn, row.get(columnIndex))).with(columnIndex).build();
            rule.getConditions().add(condition);
        } else {
            final Condition condition = builderFactory.getFieldConditionsBuilder().with(resolvePattern(rule)).with((ConditionCol52) baseColumn).with(getRealCellValue((ConditionCol52) baseColumn, row.get(columnIndex))).with(columnIndex).build();
            rule.getConditions().add(condition);
        }
    }
}
Also used : Condition(org.drools.workbench.services.verifier.api.client.index.Condition) Action(org.drools.workbench.services.verifier.api.client.index.Action) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

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