Search in sources :

Example 6 with VetoUpdatePatternInUseException

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException in project drools-wb by kiegroup.

the class ConditionColumnSynchronizerTest method checkConditionCannotBeUpdatedWhenFieldBindingIsUsedInAction.

@Test
public void checkConditionCannotBeUpdatedWhenFieldBindingIsUsedInAction() throws VetoException {
    final Pattern52 pattern = boundApplicantPattern("$a");
    final ConditionCol52 condition = ageEqualsCondition();
    condition.setBinding("$age");
    final BRLActionColumn action = actionCallMethod("$age");
    modelSynchronizer.appendColumn(pattern, condition);
    modelSynchronizer.appendColumn(action);
    try {
        final Pattern52 editedPattern = boundApplicantPattern("$a");
        final ConditionCol52 editedCondition = ageEqualsCondition();
        editedCondition.setBinding("$age2");
        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(5, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof RuleNameColumn);
    assertTrue(model.getExpandedColumns().get(2) instanceof DescriptionCol52);
    assertEquals(condition, model.getExpandedColumns().get(3));
    assertEquals(action.getChildColumns().get(0), model.getExpandedColumns().get(4));
}
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) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) VetoUpdatePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException) RuleNameColumn(org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Aggregations

VetoUpdatePatternInUseException (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException)6 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)4 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)4 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)4 VetoException (org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException)4 Test (org.junit.Test)4 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)3 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)3 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 ArrayList (java.util.ArrayList)2 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)2 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)2 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)2 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ActionCallMethod (org.drools.workbench.models.datamodel.rule.ActionCallMethod)1 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)1 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)1