Search in sources :

Example 1 with BRLConditionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testLHSWithBRLColumn_ParseToRuleModel.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
void testLHSWithBRLColumn_ParseToRuleModel() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    // All 3 rows should render, as the code is now lower down for skipping columns with empty cells
    String[][] data = new String[][] { new String[] { "1", "desc", "Gargamel", "Pupa", "50" }, new String[] { "2", "desc", "Gargamel", "", "50" }, new String[] { "3", "desc", "Gargamel", "Pupa", "" } };
    // Simple (mandatory) columns
    dtable.setRowNumberCol(new RowNumberCol52());
    dtable.setDescriptionCol(new DescriptionCol52());
    // Simple Condition
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Baddie");
    ConditionCol52 con = new ConditionCol52();
    con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con.setFactField("name");
    con.setOperator("==");
    p1.getChildColumns().add(con);
    dtable.getConditions().add(p1);
    // BRL Column
    BRLConditionColumn brl1 = new BRLConditionColumn();
    // BRL Column definition
    List<IPattern> brl1Definition = new ArrayList<IPattern>();
    FactPattern brl1DefinitionFactPattern1 = new FactPattern("Smurf");
    SingleFieldConstraint brl1DefinitionFactPattern1Constraint1 = new SingleFieldConstraint();
    brl1DefinitionFactPattern1Constraint1.setFieldType(DataType.TYPE_STRING);
    brl1DefinitionFactPattern1Constraint1.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionFactPattern1Constraint1.setFieldName("name");
    brl1DefinitionFactPattern1Constraint1.setOperator("==");
    brl1DefinitionFactPattern1Constraint1.setValue("$name");
    brl1DefinitionFactPattern1.addConstraint(brl1DefinitionFactPattern1Constraint1);
    SingleFieldConstraint brl1DefinitionFactPattern1Constraint2 = new SingleFieldConstraint();
    brl1DefinitionFactPattern1Constraint2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionFactPattern1Constraint2.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionFactPattern1Constraint2.setFieldName("age");
    brl1DefinitionFactPattern1Constraint2.setOperator("==");
    brl1DefinitionFactPattern1Constraint2.setValue("$age");
    brl1DefinitionFactPattern1.addConstraint(brl1DefinitionFactPattern1Constraint2);
    brl1Definition.add(brl1DefinitionFactPattern1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLConditionVariableColumn brl1Variable1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLConditionVariableColumn brl1Variable2 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getConditions().add(brl1);
    // Now to test conversion
    RuleModel rm = new RuleModel();
    List<BaseColumn> allColumns = dtable.getExpandedColumns();
    List<CompositeColumn<? extends BaseColumn>> allPatterns = dtable.getConditions();
    List<List<DTCellValue52>> dtData = DataUtilities.makeDataLists(data);
    // Row 0
    List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList(data[0]);
    TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider(allColumns, dtRowData0);
    p.doConditions(allColumns, allPatterns, rowDataProvider0, dtRowData0, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    assertEquals("Smurf", ((FactPattern) rm.lhs[1]).getFactType());
    // examine the first pattern
    FactPattern result0Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result0Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result0Fp1Con1 = (SingleFieldConstraint) result0Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result0Fp1Con1.getConstraintValueType());
    assertEquals("name", result0Fp1Con1.getFieldName());
    assertEquals("==", result0Fp1Con1.getOperator());
    assertEquals("Gargamel", result0Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result0Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result0Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result0Fp2Con1 = (SingleFieldConstraint) result0Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result0Fp2Con1.getConstraintValueType());
    assertEquals("name", result0Fp2Con1.getFieldName());
    assertEquals("==", result0Fp2Con1.getOperator());
    assertEquals("$name", result0Fp2Con1.getValue());
    SingleFieldConstraint result0Fp2Con2 = (SingleFieldConstraint) result0Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result0Fp2Con2.getConstraintValueType());
    assertEquals("age", result0Fp2Con2.getFieldName());
    assertEquals("==", result0Fp2Con2.getOperator());
    assertEquals("$age", result0Fp2Con2.getValue());
    // Row 1
    List<DTCellValue52> dtRowData1 = DataUtilities.makeDataRowList(data[1]);
    TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider(allColumns, dtRowData1);
    p.doConditions(allColumns, allPatterns, rowDataProvider1, dtRowData1, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    // examine the first pattern
    FactPattern result1Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result1Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result1Fp1Con1 = (SingleFieldConstraint) result1Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result1Fp1Con1.getConstraintValueType());
    assertEquals("name", result1Fp1Con1.getFieldName());
    assertEquals("==", result1Fp1Con1.getOperator());
    assertEquals("Gargamel", result1Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result1Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result1Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result1Fp2Con1 = (SingleFieldConstraint) result1Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result1Fp2Con1.getConstraintValueType());
    assertEquals("name", result1Fp2Con1.getFieldName());
    assertEquals("==", result1Fp2Con1.getOperator());
    assertEquals("$name", result1Fp2Con1.getValue());
    SingleFieldConstraint result1Fp2Con2 = (SingleFieldConstraint) result1Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result1Fp2Con2.getConstraintValueType());
    assertEquals("age", result1Fp2Con2.getFieldName());
    assertEquals("==", result1Fp2Con2.getOperator());
    assertEquals("$age", result1Fp2Con2.getValue());
    // Row 2
    List<DTCellValue52> dtRowData2 = DataUtilities.makeDataRowList(data[2]);
    TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider(allColumns, dtRowData2);
    p.doConditions(allColumns, allPatterns, rowDataProvider2, dtRowData2, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    // examine the first pattern
    FactPattern result2Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result2Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result2Fp1Con1 = (SingleFieldConstraint) result2Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result2Fp1Con1.getConstraintValueType());
    assertEquals("name", result2Fp1Con1.getFieldName());
    assertEquals("==", result2Fp1Con1.getOperator());
    assertEquals("Gargamel", result2Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result2Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result2Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result2Fp2Con1 = (SingleFieldConstraint) result2Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result2Fp2Con1.getConstraintValueType());
    assertEquals("name", result2Fp2Con1.getFieldName());
    assertEquals("==", result2Fp2Con1.getOperator());
    assertEquals("$name", result2Fp2Con1.getValue());
    SingleFieldConstraint result2Fp2Con2 = (SingleFieldConstraint) result2Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result2Fp2Con2.getConstraintValueType());
    assertEquals("age", result2Fp2Con2.getFieldName());
    assertEquals("==", result2Fp2Con2.getOperator());
    assertEquals("$age", result2Fp2Con2.getValue());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) List(java.util.List) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 2 with BRLConditionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn in project drools by kiegroup.

the class BRLRuleModelTest method testLHSNonEmptyStringValuesFreeFormLine.

@Test
public void testLHSNonEmptyStringValuesFreeFormLine() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    dt.setTableName("extended-entry");
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    FreeFormLine ffl = new FreeFormLine();
    ffl.setText("p1 : Smurf( name ==\"@{$f1}\", age == @{$f2} )");
    brlCondition.getDefinition().add(ffl);
    brlCondition.getChildColumns().add(new BRLConditionVariableColumn("$f1", DataType.TYPE_STRING, "Smurf", "name"));
    brlCondition.getChildColumns().add(new BRLConditionVariableColumn("$f2", DataType.TYPE_NUMERIC_INTEGER, "Smurf", "age"));
    dt.getConditions().add(brlCondition);
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    // Test 1
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc-row1", "Pupa", null } }));
    String drl1 = p.marshal(dt);
    final String expected1 = "//from row number: 1\n" + "//desc-row1\n" + "rule \"Row 1 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "end";
    assertEqualsIgnoreWhitespace(expected1, drl1);
    // Test 2
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 2l, "desc-row2", null, 35l } }));
    String drl2 = p.marshal(dt);
    final String expected2 = "//from row number: 1\n" + "//desc-row2\n" + "rule \"Row 2 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "end";
    assertEqualsIgnoreWhitespace(expected2, drl2);
    // Test 3
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 3l, "desc-row3", "Pupa", 35l } }));
    String drl3 = p.marshal(dt);
    final String expected3 = "//from row number: 1\n" + "//desc-row3\n" + "rule \"Row 3 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "    p1 : Smurf( name == \"Pupa\", age == 35 )\n" + "  then\n" + "end";
    assertEqualsIgnoreWhitespace(expected3, drl3);
    // Test 4
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 4l, "desc-row4", null, null } }));
    String drl4 = p.marshal(dt);
    final String expected4 = "//from row number: 1\n" + "//desc-row4\n" + "rule \"Row 4 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "end";
    assertEqualsIgnoreWhitespace(expected4, drl4);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 3 with BRLConditionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn in project drools by kiegroup.

the class BRLRuleModelTest method testDecisionTableColumnsWithLHSBoundFacts.

@Test
public void testDecisionTableColumnsWithLHSBoundFacts() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Driver");
    p1.setBoundName("$p1");
    ConditionCol52 c1 = new ConditionCol52();
    c1.setFactField("name");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setBinding("$c1");
    p1.getChildColumns().add(c1);
    dt.getConditions().add(p1);
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    FactPattern fp = new FactPattern("Driver");
    fp.setBoundName("$brl1");
    SingleFieldConstraint sfc1 = new SingleFieldConstraint();
    sfc1.setFieldBinding("$sfc1");
    sfc1.setOperator("==");
    sfc1.setFactType("Driver");
    sfc1.setFieldName("name");
    sfc1.setFieldType(DataType.TYPE_STRING);
    fp.addConstraint(sfc1);
    brlCondition.getDefinition().add(fp);
    dt.getConditions().add(brlCondition);
    ActionInsertFactCol52 ins = new ActionInsertFactCol52();
    ins.setBoundName("$ins");
    ins.setFactField("rating");
    ins.setFactType("Person");
    ins.setType(DataType.TYPE_STRING);
    dt.getActionCols().add(ins);
    BRLRuleModel model = new BRLRuleModel(dt);
    assertNotNull(model.getLHSBoundFacts());
    assertEquals(2, model.getLHSBoundFacts().size());
    assertTrue(model.getLHSBoundFacts().contains("$p1"));
    assertTrue(model.getLHSBoundFacts().contains("$brl1"));
    assertNotNull(model.getLHSBindingType("$p1"));
    assertEquals("Driver", model.getLHSBindingType("$p1"));
    assertNotNull(model.getLHSBindingType("$brl1"));
    assertEquals("Driver", model.getLHSBindingType("$brl1"));
    FactPattern r1 = model.getLHSBoundFact("$p1");
    assertNotNull(r1);
    assertTrue(r1 instanceof Pattern52FactPatternAdaptor);
    Pattern52FactPatternAdaptor raif1 = (Pattern52FactPatternAdaptor) r1;
    assertEquals("Driver", raif1.getFactType());
    FactPattern r2 = model.getLHSBoundFact("$brl1");
    assertNotNull(r2);
    assertEquals("Driver", r2.getFactType());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) Pattern52FactPatternAdaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.Pattern52FactPatternAdaptor) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) Test(org.junit.Test)

Example 4 with BRLConditionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn in project drools by kiegroup.

the class BRLRuleModelTest method testDecisionTableColumnsWithLHSBoundFields.

@Test
public void testDecisionTableColumnsWithLHSBoundFields() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Driver");
    p1.setBoundName("$p1");
    ConditionCol52 c1 = new ConditionCol52();
    c1.setFactField("name");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setBinding("$c1");
    p1.getChildColumns().add(c1);
    dt.getConditions().add(p1);
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    FactPattern fp = new FactPattern("Driver");
    fp.setBoundName("$brl1");
    SingleFieldConstraint sfc1 = new SingleFieldConstraint();
    sfc1.setFieldBinding("$sfc1");
    sfc1.setOperator("==");
    sfc1.setFactType("Driver");
    sfc1.setFieldName("name");
    sfc1.setFieldType(DataType.TYPE_STRING);
    fp.addConstraint(sfc1);
    brlCondition.getDefinition().add(fp);
    dt.getConditions().add(brlCondition);
    ActionInsertFactCol52 ins = new ActionInsertFactCol52();
    ins.setBoundName("$ins");
    ins.setFactField("rating");
    ins.setFactType("Person");
    ins.setType(DataType.TYPE_STRING);
    dt.getActionCols().add(ins);
    BRLRuleModel model = new BRLRuleModel(dt);
    FieldConstraint fcr1 = model.getLHSBoundField("$sfc1");
    assertNotNull(fcr1);
    assertTrue(fcr1 instanceof SingleFieldConstraint);
    SingleFieldConstraint fcr1sfc = (SingleFieldConstraint) fcr1;
    assertEquals("name", fcr1sfc.getFieldName());
    assertEquals(DataType.TYPE_STRING, fcr1sfc.getFieldType());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 5 with BRLConditionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn in project drools by kiegroup.

the class BRLRuleModelTest method testDecisionTableColumnsWithLHS.

@Test
public void testDecisionTableColumnsWithLHS() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Driver");
    p1.setBoundName("$p1");
    ConditionCol52 c1 = new ConditionCol52();
    c1.setFactField("name");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setBinding("$c1");
    p1.getChildColumns().add(c1);
    dt.getConditions().add(p1);
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    FactPattern fp = new FactPattern("Driver");
    fp.setBoundName("$brl1");
    SingleFieldConstraint sfc1 = new SingleFieldConstraint();
    sfc1.setFieldBinding("$sfc1");
    sfc1.setOperator("==");
    sfc1.setFactType("Driver");
    sfc1.setFieldName("name");
    sfc1.setFieldType(DataType.TYPE_STRING);
    fp.addConstraint(sfc1);
    brlCondition.getDefinition().add(fp);
    dt.getConditions().add(brlCondition);
    ActionInsertFactCol52 ins = new ActionInsertFactCol52();
    ins.setBoundName("$ins");
    ins.setFactField("rating");
    ins.setFactType("Person");
    ins.setType(DataType.TYPE_STRING);
    dt.getActionCols().add(ins);
    BRLRuleModel model = new BRLRuleModel(dt);
    assertNotNull(model.getAllVariables());
    assertEquals(5, model.getAllVariables().size());
    assertTrue(model.getAllVariables().contains("$p1"));
    assertTrue(model.getAllVariables().contains("$c1"));
    assertTrue(model.getAllVariables().contains("$ins"));
    assertTrue(model.getAllVariables().contains("$brl1"));
    assertTrue(model.getAllVariables().contains("$sfc1"));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) Test(org.junit.Test)

Aggregations

BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)85 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)62 Test (org.junit.Test)54 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)39 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)36 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)27 ArrayList (java.util.ArrayList)23 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)23 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)22 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)18 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)17 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)16 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)16 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)16 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)12 InputStream (java.io.InputStream)11 FreeFormLine (org.drools.workbench.models.datamodel.rule.FreeFormLine)11