Search in sources :

Example 6 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testLHSExpressionString2.

@Test
public void testLHSExpressionString2() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsString2";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("field1", "java.lang.String", DataType.TYPE_STRING));
    con.setOperator("==");
    con.setValue("Cheddar");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String result = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
    String expected = "rule \"test expressionsString2\"" + "\tdialect \"mvel\"\n when " + "     Person( field1 == \"Cheddar\" )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 7 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testLHSExpressionJavaEnum.

@Test
public void testLHSExpressionJavaEnum() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsJavaEnum";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("field1", "CHEESE", DataType.TYPE_COMPARABLE));
    con.setOperator("==");
    con.setValue("CHEESE.Cheddar");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsJavaEnum\"" + "\tdialect \"mvel\"\n when " + "     Person( field1 == CHEESE.Cheddar )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 8 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testLHSExpressionNestedDate.

@Test
public void testLHSExpressionNestedDate() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsNestedDate";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("favouriteCheese", "Cheese", DataType.TYPE_OBJECT));
    con.getExpressionLeftSide().appendPart(new ExpressionField("dateBrought", "java.util.Date", DataType.TYPE_DATE));
    con.setOperator("==");
    con.setValue("27-Jun-2011");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsNestedDate\"" + "\tdialect \"mvel\"\n when " + "     Person( favouriteCheese.dateBrought == \"27-Jun-2011\" )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 9 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testLHSExpressionNestedNumber.

@Test
public void testLHSExpressionNestedNumber() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsNestedNumber";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("favouriteCheese", "Cheese", DataType.TYPE_OBJECT));
    con.getExpressionLeftSide().appendPart(new ExpressionField("age", "java.lang.Integer", DataType.TYPE_NUMERIC_INTEGER));
    con.setOperator("==");
    con.setValue("55");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsNestedNumber\"" + "\tdialect \"mvel\"\n when " + "     Person( favouriteCheese.age == 55 )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 10 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testLHSExpressionNestedString.

@Test
public void testLHSExpressionNestedString() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsNestedString";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("favouriteCheese", "Cheese", DataType.TYPE_OBJECT));
    con.getExpressionLeftSide().appendPart(new ExpressionField("name", "java.lang.String", DataType.TYPE_STRING));
    con.setOperator("==");
    con.setValue("Cheedar");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsNestedString\"" + "\tdialect \"mvel\"\n when " + "     Person( favouriteCheese.name == \"Cheedar\" )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Aggregations

SingleFieldConstraintEBLeftSide (org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide)37 Test (org.junit.Test)31 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)30 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)29 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)29 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)29 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)28 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)28 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)24 ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)21 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)13 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)10 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)7 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)6 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)3 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)3 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)3 List (java.util.List)2