final GuidedDecisionTree expected = new GuidedDecisionTree();
expected.setTreeName( "test" );
final TypeNode type = new TypeNodeImpl( "Person" );
final ConstraintNode c1 = new ConstraintNodeImpl( "Person",
"name",
"==",
new StringValue( "Michael" ) );
expected.setRoot( type );
type.addChild( c1 );
addModelField( "org.drools.workbench.models.guided.dtree.backend.Person",
"this",
"org.drools.workbench.models.guided.dtree.backend.Person",
DataType.TYPE_THIS );
addModelField( "org.drools.workbench.models.guided.dtree.backend.Person",
"name",
String.class.getName(),
DataType.TYPE_STRING );
final GuidedDecisionTree model = GuidedDecisionTreeDRLPersistence.getInstance().unmarshal( drl,
"test",
dmo );
assertNotNull( model );
assertEquals( 0,
model.getParserErrors().size() );
assertEquals( expected.getTreeName(),
model.getTreeName() );
assertNotNull( model.getRoot() );
assertEquals( type.getClassName(),
model.getRoot().getClassName() );
assertFalse( model.getRoot().isBound() );
assertEquals( 1,
model.getRoot().getChildren().size() );
assertNotNull( model.getRoot().getChildren().get( 0 ) );
assertTrue( model.getRoot().getChildren().get( 0 ) instanceof ConstraintNode );
final ConstraintNode _c1 = (ConstraintNode) model.getRoot().getChildren().get( 0 );
assertEquals( c1.getClassName(),
_c1.getClassName() );
assertEquals( c1.getFieldName(),
_c1.getFieldName() );
assertEquals( c1.getOperator(),
_c1.getOperator() );
assertEquals( c1.getValue().getValue().toString(),
_c1.getValue().getValue().toString() );
}