use of org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_TypeBinding.
@Test
public void testSingleRule_TypeBinding() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " $p : Person( )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
type.setBinding("$p");
model.setRoot(type);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Double.
@Test
public void testValue_Double() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( doubleField == 1000.56 )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "doubleField", "==", new DoubleValue(1000.56));
model.setRoot(type);
type.addChild(c1);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionSetWithConstraint.
@Test
public void testSingleRule_ActionSetWithConstraint() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " $p : Person( $n : name )\n" + "then\n" + " $p.setAge( 25 );\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
type.setBinding("$p");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name");
c1.setBinding("$n");
model.setRoot(type);
type.addChild(c1);
final ActionUpdateNode action = new ActionUpdateNodeImpl(type);
action.setModify(false);
action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
c1.addChild(action);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionInsertLogical.
@Test
public void testSingleRule_ActionInsertLogical() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( )\n" + "then\n" + " Person $var0 = new Person();\n" + " $var0.setAge( 25 );\n" + " insertLogical( $var0 );\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
model.setRoot(type);
final ActionInsertNode action = new ActionInsertNodeImpl("Person");
action.setLogicalInsertion(true);
action.getFieldValues().add(new ActionFieldValueImpl("age", new IntegerValue(25)));
type.addChild(action);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_ActionModifyMultipleFields.
@Test
public void testSingleRule_ActionModifyMultipleFields() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " $p : Person( )\n" + "then\n" + " modify( $p ) {\n" + " setAge( 25 ), \n" + " setName( \"Michael\" )\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)));
action.getFieldValues().add(new ActionFieldValueImpl("name", new StringValue("Michael")));
type.addChild(action);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
Aggregations