}
@Test
public void testCompositeConstraintsRoundTrip() throws Exception {
RuleModel m = new RuleModel();
m.name = "with composite";
FactPattern p1 = new FactPattern( "Person" );
p1.setBoundName( "p1" );
m.addLhsItem( p1 );
FactPattern p = new FactPattern( "Goober" );
m.addLhsItem( p );
CompositeFieldConstraint comp = new CompositeFieldConstraint();
comp.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
p.addConstraint( comp );
final SingleFieldConstraint X = new SingleFieldConstraint();
X.setFieldName( "goo" );
X.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
X.setValue( "foo" );
X.setOperator( "==" );
X.setConnectives( new ConnectiveConstraint[ 1 ] );
X.getConnectives()[ 0 ] = new ConnectiveConstraint();
X.getConnectives()[ 0 ].setConstraintValueType( ConnectiveConstraint.TYPE_LITERAL );
X.getConnectives()[ 0 ].setOperator( "|| ==" );
X.getConnectives()[ 0 ].setValue( "bar" );
comp.addConstraint( X );
final SingleFieldConstraint Y = new SingleFieldConstraint();
Y.setFieldName( "goo2" );
Y.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
Y.setValue( "foo" );
Y.setOperator( "==" );
comp.addConstraint( Y );
CompositeFieldConstraint comp2 = new CompositeFieldConstraint();
comp2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_AND );
final SingleFieldConstraint Q1 = new SingleFieldConstraint();
Q1.setFieldName( "goo" );
Q1.setOperator( "==" );
Q1.setValue( "whee" );
Q1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
comp2.addConstraint( Q1 );
final SingleFieldConstraint Q2 = new SingleFieldConstraint();
Q2.setFieldName( "gabba" );
Q2.setOperator( "==" );
Q2.setValue( "whee" );
Q2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
comp2.addConstraint( Q2 );
//now nest it
comp.addConstraint( comp2 );
final SingleFieldConstraint Z = new SingleFieldConstraint();
Z.setFieldName( "goo3" );
Z.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
Z.setValue( "foo" );
Z.setOperator( "==" );
p.addConstraint( Z );
ActionInsertFact ass = new ActionInsertFact( "Whee" );
m.addRhsItem( ass );
String xml = BRXMLPersistence.getInstance().marshal( m );
//System.err.println(xml);
RuleModel m2 = BRXMLPersistence.getInstance().unmarshal( xml );
assertNotNull( m2 );
assertEquals( "with composite",
m2.name );
assertEquals( m2.lhs.length,