Search in sources :

Example 31 with GuidedDecisionTable52

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

the class GuidedDTDRLPersistenceTest method testRHSWithBRLColumn_ParseToDRL.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into DRL
void testRHSWithBRLColumn_ParseToDRL() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    // All three rows are entered, some columns with optional data
    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 Action
    ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
    a1.setBoundName("$b");
    a1.setFactType("Baddie");
    a1.setFactField("name");
    a1.setType(DataType.TYPE_STRING);
    dtable.getActionCols().add(a1);
    // BRL Column
    BRLActionColumn brl1 = new BRLActionColumn();
    // BRL Column definition
    List<IAction> brl1Definition = new ArrayList<IAction>();
    ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact("Smurf");
    ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue("name", "$name", DataType.TYPE_STRING);
    brl1DefinitionAction1FieldValue1.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue1);
    ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue("age", "$age", DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionAction1FieldValue2.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue2);
    brl1Definition.add(brl1DefinitionAction1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getActionCols().add(brl1);
    dtable.setData(DataUtilities.makeDataLists(data));
    // Now to test conversion
    int ruleStartIndex;
    int action1StartIndex;
    int action2StartIndex;
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dtable);
    // Row 0
    ruleStartIndex = drl.indexOf("//from row number: 1");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName( \"Pupa\" );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    // Row 1
    ruleStartIndex = drl.indexOf("//from row number: 2");
    int ruleEndIndex = drl.indexOf("//from row number: 3");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName(", ruleStartIndex);
    assertFalse(action2StartIndex < ruleEndIndex);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    // Row 2
    ruleStartIndex = drl.indexOf("//from row number: 3");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName( \"Pupa\" );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", ruleStartIndex);
    assertTrue(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ArrayList(java.util.ArrayList) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 32 with GuidedDecisionTable52

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

the class GuidedDTDRLPersistenceTest method testDefaultValue.

@Test
public void testDefaultValue() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("$c");
    p1.setFactType("CheeseLover");
    ConditionCol52 c = new ConditionCol52();
    c.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c.setFactField("favouriteCheese");
    c.setDefaultValue(new DTCellValue52("cheddar"));
    c.setOperator("==");
    p1.getChildColumns().add(c);
    dt.getConditions().add(p1);
    // With provided getValue()
    String[][] data = new String[][] { new String[] { "1", "desc", "edam" } };
    dt.setData(DataUtilities.makeDataLists(data));
    String drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
    assertFalse(drl.indexOf("$c : CheeseLover( favouriteCheese == \"edam\" )") == -1);
    // Without provided getValue() #1
    data = new String[][] { new String[] { "1", "desc", null } };
    dt.setData(DataUtilities.makeDataLists(data));
    drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
    assertTrue(drl.indexOf("$c : CheeseLover( favouriteCheese == \"cheddar\" )") == -1);
    // Without provided getValue() #2
    data = new String[][] { new String[] { "1", "desc", "" } };
    dt.setData(DataUtilities.makeDataLists(data));
    drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
    assertTrue(drl.indexOf("$c : CheeseLover( favouriteCheese == \"cheddar\" )") == -1);
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) 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) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 33 with GuidedDecisionTable52

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

the class GuidedDTDRLPersistenceTest method testLHSInOperator.

@Test
public void testLHSInOperator() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    dt.setTableName("extended-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    ConditionCol52 cc1 = new ConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_STRING);
    cc1.setFactField("name");
    cc1.setOperator("in");
    p1.getChildColumns().add(cc1);
    ConditionCol52 cc2 = new ConditionCol52();
    cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    cc2.setFactField("age");
    cc2.setOperator("in");
    p1.getChildColumns().add(cc2);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", "Pupa, Brains, \"John, Snow\"", "55, 66" }, new Object[] { 2l, "desc", "", "" } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( name in ( \"Pupa\", \"Brains\", \"John, Snow\" ) , age in ( 55, 66 ) )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( )", index + 1);
    assertFalse(index > -1);
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) 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) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 34 with GuidedDecisionTable52

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

the class GuidedDTDRLPersistenceTest method testInOperator.

@Test
public void testInOperator() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableName("michael");
    AttributeCol52 attr = new AttributeCol52();
    attr.setAttribute("salience");
    attr.setDefaultValue(new DTCellValue52("66"));
    dt.getAttributeCols().add(attr);
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("f1");
    p1.setFactType("Driver");
    ConditionCol52 con = new ConditionCol52();
    con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con.setFactField("age");
    con.setHeader("Driver f1 age");
    con.setOperator("==");
    p1.getChildColumns().add(con);
    ConditionCol52 con2 = new ConditionCol52();
    con2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con2.setFactField("name");
    con2.setHeader("Driver f1 name");
    con2.setOperator("in");
    p1.getChildColumns().add(con2);
    ConditionCol52 con3 = new ConditionCol52();
    con3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_RET_VALUE);
    con3.setFactField("rating");
    con3.setHeader("Driver rating");
    con3.setOperator("==");
    p1.getChildColumns().add(con3);
    ConditionCol52 con4 = new ConditionCol52();
    con4.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
    con4.setHeader("Driver 2 pimp");
    con4.setFactField("(not needed)");
    p1.getChildColumns().add(con4);
    dt.getConditions().add(p1);
    ActionInsertFactCol52 ins = new ActionInsertFactCol52();
    ins.setBoundName("ins");
    ins.setFactType("Cheese");
    ins.setFactField("price");
    ins.setType(DataType.TYPE_NUMERIC_INTEGER);
    dt.getActionCols().add(ins);
    ActionRetractFactCol52 ret = new ActionRetractFactCol52();
    dt.getActionCols().add(ret);
    ActionSetFieldCol52 set = new ActionSetFieldCol52();
    set.setBoundName("f1");
    set.setFactField("goo1");
    set.setType(DataType.TYPE_STRING);
    dt.getActionCols().add(set);
    ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
    set2.setBoundName("f1");
    set2.setFactField("goo2");
    set2.setDefaultValue(new DTCellValue52("whee"));
    set2.setType(DataType.TYPE_STRING);
    dt.getActionCols().add(set2);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "42", "33", "michael, manik", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", "f2" }, new String[] { "2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", null } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    assertTrue(drl.indexOf("name in ( \"michael\",") > 0);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) 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) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 35 with GuidedDecisionTable52

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

the class GuidedDTDRLPersistenceTest method testRHSWithBRLColumn_ParseToRuleModel.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
void testRHSWithBRLColumn_ParseToRuleModel() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    // All three rows are entered, some columns with optional data
    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 Action
    ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
    a1.setBoundName("$b");
    a1.setFactType("Baddie");
    a1.setFactField("name");
    a1.setType(DataType.TYPE_STRING);
    dtable.getActionCols().add(a1);
    // BRL Column
    BRLActionColumn brl1 = new BRLActionColumn();
    // BRL Column definition
    List<IAction> brl1Definition = new ArrayList<IAction>();
    ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact("Smurf");
    ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue("name", "$name", DataType.TYPE_STRING);
    brl1DefinitionAction1FieldValue1.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue1);
    ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue("age", "$age", DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionAction1FieldValue2.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue2);
    brl1Definition.add(brl1DefinitionAction1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getActionCols().add(brl1);
    // Now to test conversion
    RuleModel rm = new RuleModel();
    List<BaseColumn> allColumns = dtable.getExpandedColumns();
    List<ActionCol52> allActions = dtable.getActionCols();
    // Row 0
    List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList(data[0]);
    TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider(allColumns, dtRowData0);
    p.doActions(allColumns, allActions, rowDataProvider0, dtRowData0, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result0Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result0Action1.getFieldValues().length);
    ActionFieldValue result0Action1FieldValue1 = (ActionFieldValue) result0Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result0Action1FieldValue1.getType());
    assertEquals("name", result0Action1FieldValue1.getField());
    assertEquals("Gargamel", result0Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result0Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result0Action2.getFieldValues().length);
    ActionFieldValue result0Action2FieldValue1 = (ActionFieldValue) result0Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result0Action2FieldValue1.getType());
    assertEquals("name", result0Action2FieldValue1.getField());
    assertEquals("$name", result0Action2FieldValue1.getValue());
    ActionFieldValue result0Action2FieldValue2 = (ActionFieldValue) result0Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result0Action2FieldValue2.getType());
    assertEquals("age", result0Action2FieldValue2.getField());
    assertEquals("$age", result0Action2FieldValue2.getValue());
    // Row 1
    List<DTCellValue52> dtRowData1 = DataUtilities.makeDataRowList(data[1]);
    TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider(allColumns, dtRowData1);
    p.doActions(allColumns, allActions, rowDataProvider1, dtRowData1, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result1Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result1Action1.getFieldValues().length);
    ActionFieldValue result1Action1FieldValue1 = (ActionFieldValue) result1Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result1Action1FieldValue1.getType());
    assertEquals("name", result1Action1FieldValue1.getField());
    assertEquals("Gargamel", result1Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result1Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result1Action2.getFieldValues().length);
    ActionFieldValue result1Action2FieldValue1 = (ActionFieldValue) result1Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result1Action2FieldValue1.getType());
    assertEquals("name", result1Action2FieldValue1.getField());
    assertEquals("$name", result1Action2FieldValue1.getValue());
    ActionFieldValue result1Action2FieldValue2 = (ActionFieldValue) result1Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result1Action2FieldValue2.getType());
    assertEquals("age", result1Action2FieldValue2.getField());
    assertEquals("$age", result1Action2FieldValue2.getValue());
    // Row 2
    List<DTCellValue52> dtRowData2 = DataUtilities.makeDataRowList(data[2]);
    TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider(allColumns, dtRowData2);
    p.doActions(allColumns, allActions, rowDataProvider2, dtRowData2, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result2Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result2Action1.getFieldValues().length);
    ActionFieldValue result2Action1FieldValue1 = (ActionFieldValue) result2Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result2Action1FieldValue1.getType());
    assertEquals("name", result2Action1FieldValue1.getField());
    assertEquals("Gargamel", result2Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result2Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result2Action2.getFieldValues().length);
    ActionFieldValue result2Action2FieldValue1 = (ActionFieldValue) result2Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result2Action2FieldValue1.getType());
    assertEquals("name", result2Action2FieldValue1.getField());
    assertEquals("$name", result2Action2FieldValue1.getValue());
    ActionFieldValue result3Action2FieldValue2 = (ActionFieldValue) result2Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result3Action2FieldValue2.getType());
    assertEquals("age", result3Action2FieldValue2.getField());
    assertEquals("$age", result3Action2FieldValue2.getValue());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) Test(org.junit.Test)

Aggregations

GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)262 Test (org.junit.Test)193 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)92 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)74 Path (org.uberfire.backend.vfs.Path)52 ArrayList (java.util.ArrayList)51 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)51 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)47 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)39 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)37 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)35 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)33 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)33 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)33 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)32 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)31 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)27 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)27 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26