Search in sources :

Example 36 with FreeFormLine

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);
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 37 with FreeFormLine

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());
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 38 with FreeFormLine

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());
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) Test(org.junit.Test)

Example 39 with FreeFormLine

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);
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) TestIAction(org.drools.workbench.models.commons.backend.rule.actions.TestIAction) IAction(org.drools.workbench.models.datamodel.rule.IAction) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) PackageDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.PackageDataModelOracleImpl) Test(org.junit.Test)

Example 40 with 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);
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

FreeFormLine (org.drools.workbench.models.datamodel.rule.FreeFormLine)64 Test (org.junit.Test)49 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)29 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)24 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)22 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)22 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)18 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)18 IAction (org.drools.workbench.models.datamodel.rule.IAction)17 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)14 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)14 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)12 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)11 ArrayList (java.util.ArrayList)10 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)10 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)10 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)10 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)9 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)9