use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCannotBeUpdatedWhenBindingIsUsedInAction.
@Test
public void checkBRLFragmentConditionCannotBeUpdatedWhenBindingIsUsedInAction() throws VetoException {
final BRLConditionColumn column = new BRLConditionColumn();
column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
}
}));
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column.getChildColumns().add(columnV0);
column.setHeader("col1");
columnV0.setHeader("col1v0");
modelSynchronizer.appendColumn(column);
final ActionSetFieldCol52 action = new ActionSetFieldCol52() {
{
setBoundName("$a");
setFactField("age");
setHeader("action1");
}
};
modelSynchronizer.appendColumn(action);
try {
final BRLConditionColumn editedColumn = new BRLConditionColumn();
editedColumn.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a2");
}
}));
final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
editedColumn.getChildColumns().add(editedColumnV0);
editedColumn.setHeader("col1");
editedColumnV0.setHeader("col1v0");
modelSynchronizer.updateColumn(column, editedColumn);
fail("Deletion 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(columnV0, model.getExpandedColumns().get(3));
assertEquals(action, model.getExpandedColumns().get(4));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkConditionCanBeDeletedWithSingleChildColumnWithNoAction.
@Test
public void checkConditionCanBeDeletedWithSingleChildColumnWithNoAction() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition = ageEqualsCondition();
modelSynchronizer.appendColumn(pattern, condition);
try {
modelSynchronizer.deleteColumn(condition);
} catch (VetoException veto) {
fail("Deletion should have been permitted.");
}
assertEquals(3, model.getExpandedColumns().size());
assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
assertTrue(model.getExpandedColumns().get(1) instanceof RuleNameColumn);
assertTrue(model.getExpandedColumns().get(2) instanceof DescriptionCol52);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException 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(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, model.getExpandedColumns().get(4));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException 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(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, model.getExpandedColumns().get(4));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException 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));
}
Aggregations