use of org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_FieldBinding.
@Test
public void testSingleRule_FieldBinding() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( $n : name )\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");
c1.setBinding("$n");
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.GuidedDecisionTree in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testSingleRule_SingleConstraint.
@Test
public void testSingleRule_SingleConstraint() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( name == \"Michael\" )\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"));
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.GuidedDecisionTree in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Date.
@Test
public void testValue_Date() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( dateField == \"15-Jul-1984\" )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "dateField", "==", new DateValue(new Date(84, 6, 15)));
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.GuidedDecisionTree in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Byte.
@Test
public void testValue_Byte() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( byteField == 100 )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "byteField", "==", new ByteValue(new Byte("100")));
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.GuidedDecisionTree in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceUnmarshallingMessagesTest method testSingleRule_DataTypeNotFound.
@Test
public void testSingleRule_DataTypeNotFound() throws Exception {
final String drl = "rule \"test_0\"\n" + "when \n" + " Person( name == \"Michael\" )\n" + "then \n" + "end";
final GuidedDecisionTree expected = new GuidedDecisionTree();
expected.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
expected.setRoot(type);
addModelField("Person", "this", "Person", DataType.TYPE_THIS);
final GuidedDecisionTree model = getAndTestUnmarshalledModel(drl, "test", 1);
assertEquals(expected.getTreeName(), model.getTreeName());
assertNull(model.getRoot());
assertEquals("test_0", model.getParserErrors().get(0).getOriginalRuleName());
assertEqualsIgnoreWhitespace(drl, model.getParserErrors().get(0).getOriginalDrl());
assertNotNull(model.getParserErrors().get(0).getMessages());
assertEquals(1, model.getParserErrors().get(0).getMessages().size());
assertTrue(model.getParserErrors().get(0).getMessages().get(0) instanceof DataTypeNotFoundParserMessage);
final String drl2 = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(drl, drl2);
}
Aggregations