Search in sources :

Example 31 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetActionRetract.

@Test
public void testSingleRule_ActionSetActionRetract() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\n" + "  $p.setAge( 25 );\n" + "  retract( $p );\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    model.setRoot(type);
    final ActionUpdateNode action1 = new ActionUpdateNodeImpl(type);
    action1.setModify(false);
    action1.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    type.addChild(action1);
    final ActionRetractNode action2 = new ActionRetractNodeImpl(type);
    action1.addChild(action2);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) ActionRetractNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) ActionRetractNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) Test(org.junit.Test)

Example 32 with ActionFieldValueImpl

use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl in project drools by kiegroup.

the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionModify.

@Test
public void testSingleRule_ActionModify() throws Exception {
    final String expected = "rule \"test_0\"" + "when\n" + "  $p : Person( )\n" + "then\n" + "  modify( $p ) {\n" + "    setAge( 25 )\n" + "  }\n" + "end";
    final GuidedDecisionTree model = new GuidedDecisionTree();
    model.setTreeName("test");
    final TypeNode type = new TypeNodeImpl("Person");
    type.setBinding("$p");
    model.setRoot(type);
    final ActionUpdateNode action = new ActionUpdateNodeImpl(type);
    action.setModify(true);
    action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
    type.addChild(action);
    final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : TypeNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl) ActionUpdateNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode) IntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue) BigIntegerValue(org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue) ActionUpdateNodeImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) ActionFieldValueImpl(org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl) Test(org.junit.Test)

Aggregations

ActionFieldValueImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionFieldValueImpl)32 TypeNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode)30 GuidedDecisionTree (org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree)29 TypeNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.TypeNodeImpl)29 Test (org.junit.Test)29 ActionUpdateNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionUpdateNode)22 ActionUpdateNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionUpdateNodeImpl)22 BigIntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.BigIntegerValue)21 IntegerValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.IntegerValue)21 BigInteger (java.math.BigInteger)10 ActionInsertNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionInsertNode)9 ActionInsertNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionInsertNodeImpl)9 DateValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.DateValue)9 Calendar (java.util.Calendar)8 ActionRetractNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ActionRetractNode)5 ConstraintNode (org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode)5 ActionRetractNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ActionRetractNodeImpl)5 StringValue (org.drools.workbench.models.guided.dtree.shared.model.values.impl.StringValue)5 Date (java.util.Date)4 ConstraintNodeImpl (org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl)4