"then \n" +
" java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(\"dd-MMM-yyyy\");\n" +
" $p.setDateOfBirth( sdf.parse(\"15-Jul-1985\") );\n" +
"end";
final GuidedDecisionTree expected = new GuidedDecisionTree();
expected.setTreeName( "test" );
final TypeNode type = new TypeNodeImpl( "Person" );
type.setBinding( "$p" );
expected.setRoot( type );
final ActionUpdateNode action = new ActionUpdateNodeImpl( type );
action.setModify( false );
final Calendar dob = Calendar.getInstance();
dob.set( Calendar.YEAR,
1985 );
dob.set( Calendar.MONTH,
6 );
dob.set( Calendar.DATE,
15 );
dob.set( Calendar.HOUR_OF_DAY,
0 );
dob.set( Calendar.MINUTE,
0 );
dob.set( Calendar.SECOND,
0 );
action.getFieldValues().add( new ActionFieldValueImpl( "dateOfBirth",
new DateValue( dob.getTime() ) ) );
type.addChild( action );
addModelField( "Person",
"this",
"Person",
DataType.TYPE_THIS );
addModelField( "Person",
"dateOfBirth",
Date.class.getName(),
DataType.TYPE_DATE );
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() );
assertTrue( model.getRoot().isBound() );
assertEquals( type.getBinding(),
model.getRoot().getBinding() );
assertEquals( 1,
model.getRoot().getChildren().size() );
assertNotNull( model.getRoot().getChildren().get( 0 ) );
assertTrue( model.getRoot().getChildren().get( 0 ) instanceof ActionUpdateNode );
final ActionUpdateNode _action = (ActionUpdateNode) model.getRoot().getChildren().get( 0 );
assertEquals( action.getBoundNode().getBinding(),
_action.getBoundNode().getBinding() );
assertEquals( action.isModify(),
_action.isModify() );