use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryActionSet.
@Test
public void testLimitedEntryActionSet() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setFieldType(DataType.TYPE_BOOLEAN);
cc1.setFactField("isSmurf");
cc1.setOperator("==");
cc1.setValue(new DTCellValue52("true"));
p1.getChildColumns().add(cc1);
LimitedEntryActionSetFieldCol52 asf1 = new LimitedEntryActionSetFieldCol52();
asf1.setBoundName("p1");
asf1.setFactField("colour");
asf1.setValue(new DTCellValue52("Blue"));
dt.getActionCols().add(asf1);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", true, false } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( isSmurf == true )");
assertTrue(index > -1);
index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
assertTrue(index > -1);
index = drl.indexOf("Smurf( isSmurf == true )", index + 1);
assertTrue(index > -1);
index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
assertFalse(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryConditionsNoConstraints.
@Test
public void testLimitedEntryConditionsNoConstraints() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
// This is a hack consistent with how the Expanded Form decision table
// works. I wouldn't be too surprised if this changes at some time, but
// GuidedDTDRLPersistence.marshal does not support empty patterns at
// present.
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setValue(new DTCellValue52("y"));
p1.getChildColumns().add(cc1);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true }, new Object[] { 2l, "desc", false } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( )", index + 1);
assertFalse(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNullOperatorWithNullValues.
@Test
public void testLimitedEntryLHSIsNullOperatorWithNullValues() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setFieldType(DataType.TYPE_STRING);
cc1.setFactField("name");
cc1.setOperator("== null");
p1.getChildColumns().add(cc1);
LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
cc2.setFactField("age");
cc2.setOperator("== null");
p1.getChildColumns().add(cc2);
LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc3.setFieldType(DataType.TYPE_DATE);
cc3.setFactField("dateOfBirth");
cc3.setOperator("== null");
p1.getChildColumns().add(cc3);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true, true }, new Object[] { 2l, "desc", null, null, null } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( name == null , age == null , dateOfBirth == null )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( )", index + 1);
assertFalse(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryConditionsConstraints2.
@Test
public void testLimitedEntryConditionsConstraints2() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setFieldType(DataType.TYPE_STRING);
cc1.setFactField("name");
cc1.setOperator("==");
cc1.setValue(new DTCellValue52("Pupa"));
p1.getChildColumns().add(cc1);
LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc2.setFieldType(DataType.TYPE_STRING);
cc2.setFactField("name");
cc2.setOperator("==");
cc2.setValue(new DTCellValue52("Smurfette"));
p1.getChildColumns().add(cc2);
LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc3.setFieldType(DataType.TYPE_STRING);
cc3.setFactField("colour");
cc3.setOperator("==");
cc3.setValue(new DTCellValue52("Blue"));
p1.getChildColumns().add(cc3);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, false, true }, new Object[] { 2l, "desc", false, true, true }, new Object[] { 3l, "desc", false, false, true } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( name == \"Pupa\" , colour == \"Blue\" )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( name == \"Smurfette\" , colour == \"Blue\" )", index + 1);
assertTrue(index > -1);
index = drl.indexOf("Smurf( colour == \"Blue\" )", index + 1);
assertTrue(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNotNullOperatorWithNullValues.
@Test
public void testLimitedEntryLHSIsNotNullOperatorWithNullValues() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setFieldType(DataType.TYPE_STRING);
cc1.setFactField("name");
cc1.setOperator("!= null");
p1.getChildColumns().add(cc1);
LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
cc2.setFactField("age");
cc2.setOperator("!= null");
p1.getChildColumns().add(cc2);
LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc3.setFieldType(DataType.TYPE_DATE);
cc3.setFactField("dateOfBirth");
cc3.setOperator("!= null");
p1.getChildColumns().add(cc3);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true, true }, new Object[] { 2l, "desc", null, null, null } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( name != null , age != null , dateOfBirth != null )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( )", index + 1);
assertFalse(index > -1);
}
Aggregations