use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Boolean.
@Test
public void testValue_Boolean() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( booleanField == true )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "booleanField", "==", new BooleanValue(true));
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.impl.ConstraintNodeImpl in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Float.
@Test
public void testValue_Float() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( floatField == 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", "floatField", "==", new FloatValue(1000.56f));
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.impl.ConstraintNodeImpl in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testMultipleRules_MultiplePatterns.
@Test
public void testMultipleRules_MultiplePatterns() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( name == \"Michael\" )\n" + " Address( country == \"England\" )\n" + "then\n" + "end" + "rule \"test_1\"" + "when\n" + " Person( name == \"Michael\" )\n" + " Address( country == \"Norway\" )\n" + "then\n" + "end" + "rule \"test_2\"" + "when\n" + " Person( name == \"Fred\" )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type1 = new TypeNodeImpl("Person");
final ConstraintNode c1a = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Michael"));
final ConstraintNode c1b = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Fred"));
final TypeNode type2 = new TypeNodeImpl("Address");
final ConstraintNode c2a = new ConstraintNodeImpl("Address", "country", "==", new StringValue("England"));
final ConstraintNode c2b = new ConstraintNodeImpl("Address", "country", "==", new StringValue("Norway"));
model.setRoot(type1);
type1.addChild(c1a);
type1.addChild(c1b);
c1a.addChild(type2);
type2.addChild(c2a);
type2.addChild(c2b);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_MultipleConstraints.
@Test
public void testSingleRule_MultipleConstraints() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( name == \"Michael\", age == 41 )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Michael"));
final ConstraintNode c2 = new ConstraintNodeImpl("Person", "age", "==", new IntegerValue(41));
model.setRoot(type);
type.addChild(c1);
c1.addChild(c2);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.impl.ConstraintNodeImpl in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testMultipleRules_3Rules.
@Test
public void testMultipleRules_3Rules() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( name == \"Michael\" )\n" + "then\n" + "end" + "rule \"test_1\"" + "when\n" + " Person( age == 41 )\n" + "then\n" + "end" + "rule \"test_2\"" + "when\n" + " Person( gender == \"Male\" )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Michael"));
final ConstraintNode c2 = new ConstraintNodeImpl("Person", "age", "==", new IntegerValue(41));
final ConstraintNode c3 = new ConstraintNodeImpl("Person", "gender", "==", new StringValue("Male"));
model.setRoot(type);
type.addChild(c1);
type.addChild(c2);
type.addChild(c3);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
Aggregations