use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceTest method testFromCollectFreeFormLineFirstValue.
@Test
public void testFromCollectFreeFormLineFirstValue() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FreeFormLine ffl = new FreeFormLine();
ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )");
FactPattern fp = new FactPattern("java.util.List");
FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
fac.setRightPattern(ffl);
fac.setFactPattern(fp);
m.addLhsItem(fac);
String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end";
m.addRow(new String[] { "foo", null });
checkMarshall(expected, m);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleTemplateModelXMLPersistenceTest method testFreeFormLine.
@Test
public void testFreeFormLine() {
TemplateModel m = new TemplateModel();
m.name = "with composite";
m.lhs = new IPattern[1];
m.rhs = new IAction[1];
FreeFormLine fl = new FreeFormLine();
fl.setText("Person()");
m.lhs[0] = fl;
FreeFormLine fr = new FreeFormLine();
fr.setText("fun()");
m.rhs[0] = fr;
String xml = RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(m);
assertNotNull(xml);
RuleModel m_ = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(xml);
assertEquals(1, m_.lhs.length);
assertEquals(1, m_.rhs.length);
assertEquals("Person()", ((FreeFormLine) m_.lhs[0]).getText());
assertEquals("fun()", ((FreeFormLine) m_.rhs[0]).getText());
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RHSClassDependencyVisitorTest method visitFreeFormLine.
@Test
public void visitFreeFormLine() {
visitor.visit(new FreeFormLine());
assertTrue(visitor.getRHSClasses().isEmpty());
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleModelDRLPersistenceExtensionsTest method unmarshalWithoutExtensions.
@Test
public void unmarshalWithoutExtensions() {
RuleModel ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshal(DRL_RULE, Collections.emptyList(), new PackageDataModelOracleImpl());
assertEquals(1, ruleModel.rhs.length);
IAction iAction = ruleModel.rhs[0];
assertTrue(iAction instanceof FreeFormLine);
}
use of org.drools.workbench.models.datamodel.rule.FreeFormLine in project drools by kiegroup.
the class RuleModelDRLPersistenceTest method testEmptyFreeForm.
@Test
public void testEmptyFreeForm() {
// https://bugzilla.redhat.com/show_bug.cgi?id=1058247
RuleModel m = new RuleModel();
m.name = "Empty FreeFormLine";
m.lhs = new IPattern[1];
m.rhs = new IAction[1];
FreeFormLine fl = new FreeFormLine();
m.lhs[0] = fl;
FreeFormLine fr = new FreeFormLine();
m.rhs[0] = fr;
String drl = ruleModelPersistence.marshal(m);
assertNotNull(drl);
}
Aggregations