Search in sources :

Example 51 with DescriptionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52 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(4, model.getExpandedColumns().size());
    assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
    assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
    assertEquals(columnV0, model.getExpandedColumns().get(2));
    assertEquals(action, model.getExpandedColumns().get(3));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) VetoUpdatePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 52 with DescriptionCol52

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

the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCannotBeDeletedWhenFieldBindingIsUsedInAction.

@Test
public void checkBRLFragmentConditionCannotBeDeletedWhenFieldBindingIsUsedInAction() throws VetoException {
    final BRLConditionColumn column = new BRLConditionColumn();
    column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {

        {
            setBoundName("$a");
            addConstraint(new SingleFieldConstraint("age") {

                {
                    setBoundName("$age");
                }
            });
        }
    }));
    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 BRLActionColumn action = new BRLActionColumn();
    action.setDefinition(Collections.singletonList(new ActionCallMethod() {

        {
            setVariable("$age");
            setMethodName("toString()");
        }
    }));
    final BRLActionVariableColumn columnV1 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    action.getChildColumns().add(columnV1);
    action.setHeader("col2");
    columnV1.setHeader("col2v0");
    modelSynchronizer.appendColumn(action);
    try {
        modelSynchronizer.deleteColumn(column);
        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(columnV0, model.getExpandedColumns().get(2));
    assertEquals(action.getChildColumns().get(0), model.getExpandedColumns().get(3));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) 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 53 with DescriptionCol52

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

the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCanBeUpdatedWithNewConstraintOnBoundPatternUsedInAction.

@Test
public void checkBRLFragmentConditionCanBeUpdatedWithNewConstraintOnBoundPatternUsedInAction() 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("$a");
            }
        }));
        final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
        final BRLConditionVariableColumn editedColumnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
        editedColumn.getChildColumns().add(editedColumnV0);
        editedColumn.getChildColumns().add(editedColumnV1);
        editedColumn.setHeader("col1");
        editedColumnV0.setHeader("col1v0");
        editedColumnV1.setHeader("col1v1");
        modelSynchronizer.updateColumn(column, editedColumn);
        assertEquals(5, model.getExpandedColumns().size());
        assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
        assertTrue(model.getExpandedColumns().get(1) instanceof DescriptionCol52);
        assertEquals(editedColumnV0, model.getExpandedColumns().get(2));
        assertEquals(editedColumnV1, model.getExpandedColumns().get(3));
        assertEquals(action, model.getExpandedColumns().get(4));
    } catch (VetoException veto) {
        fail("VetoUpdatePatternInUseException was not expected.");
    }
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 54 with DescriptionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52 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 55 with DescriptionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52 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(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.getChildColumns().get(0), 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) 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) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Aggregations

DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)68 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)66 Test (org.junit.Test)59 ArrayList (java.util.ArrayList)47 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)43 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)33 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)24 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)23 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)23 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)22 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)22 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)21 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)21 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)21 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)19 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)19 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)19 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)18 IOException (java.io.IOException)17 InputStream (java.io.InputStream)17