"when \n" +
" Person( name == \"Fred\" )\n" +
"then \n" +
"end \n";
final GuidedDecisionTree expected = new GuidedDecisionTree();
expected.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" ) );
expected.setRoot( type1 );
type1.addChild( c1a );
type1.addChild( c1b );
c1a.addChild( type2 );
type2.addChild( c2a );
type2.addChild( c2b );
addModelField( "Person",
"this",
"Person",
DataType.TYPE_THIS );
addModelField( "Person",
"name",
String.class.getName(),
DataType.TYPE_STRING );
addModelField( "Address",
"this",
"Address",
DataType.TYPE_THIS );
addModelField( "Address",
"country",
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() );
final TypeNode _t1 = model.getRoot();
assertEquals( type1.getClassName(),
_t1.getClassName() );
assertFalse( _t1.isBound() );