use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testFreeFormLineBothValues.
@Test
public void testFreeFormLineBothValues() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FreeFormLine ffl = new FreeFormLine();
ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )");
m.addLhsItem(ffl);
String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "Person( field1 == \"foo\", field2 == \"bar\" ) \n" + "then\n" + "end";
m.addRow(new String[] { "foo", "bar" });
checkMarshall(expected, m);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testFreeFormLineSecondValue.
@Test
public void testFreeFormLineSecondValue() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FreeFormLine ffl = new FreeFormLine();
ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )");
m.addLhsItem(ffl);
String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end";
m.addRow(new String[] { null, "bar" });
checkMarshall(expected, m);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testActionFreeFormLineBothValues.
@Test
public void testActionFreeFormLineBothValues() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FreeFormLine ffl = new FreeFormLine();
ffl.setText("System.println( \"@{f1}\" + \"@{f2}\" );");
m.addRhsItem(ffl);
String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "System.println( \"foo\" + \"bar\" );" + "end";
m.addRow(new String[] { "foo", "bar" });
checkMarshall(expected, m);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testEmptyFreeForm.
@Test
public void testEmptyFreeForm() {
// https://bugzilla.redhat.com/show_bug.cgi?id=1058247
TemplateModel m = new TemplateModel();
m.name = "Empty FreeFormLine";
FreeFormLine fl = new FreeFormLine();
m.addLhsItem(fl);
FactPattern fp = new FactPattern("Person");
fp.setBoundName("$p");
SingleFieldConstraint sfc1 = new SingleFieldConstraint();
sfc1.setFieldName("field1");
sfc1.setFieldType(DataType.TYPE_STRING);
sfc1.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
sfc1.setValue("$f1");
sfc1.setOperator("==");
fp.addConstraint(sfc1);
m.addLhsItem(fp);
FreeFormLine fr = new FreeFormLine();
m.addRhsItem(fr);
ActionSetField asf = new ActionSetField("$p");
ActionFieldValue afv0 = new ActionFieldValue();
afv0.setNature(FieldNatureType.TYPE_TEMPLATE);
afv0.setType(DataType.TYPE_STRING);
afv0.setField("field1");
afv0.setValue("$asf1");
asf.addFieldValue(afv0);
m.addRhsItem(asf);
String expected = "rule \"Empty FreeFormLine_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "$p : Person( field1 == \"foo\" )\n" + "then\n" + "$p.setField1(\"bar\");\n" + "end";
m.addRow(new String[] { "foo", "bar" });
checkMarshall(expected, m);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testFreeFormLineFirstValue.
@Test
public void testFreeFormLineFirstValue() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FreeFormLine ffl = new FreeFormLine();
ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )");
m.addLhsItem(ffl);
String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end";
m.addRow(new String[] { "foo", null });
checkMarshall(expected, m);
}
Aggregations