m );
}
@Test
public void testCompositeConstraintWithConnectiveConstraintFirstValue() {
TemplateModel m = new TemplateModel();
m.name = "t1";
FactPattern p1 = new FactPattern( "Person" );
m.addLhsItem( p1 );
CompositeFieldConstraint comp = new CompositeFieldConstraint();
comp.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
p1.addConstraint( comp );
final SingleFieldConstraint X = new SingleFieldConstraint();
X.setFieldName( "field1" );
X.setFieldType( DataType.TYPE_STRING );
X.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
X.setValue( "$f1" );
X.setOperator( "==" );
comp.addConstraint( X );
ConnectiveConstraint connective = new ConnectiveConstraint();
connective.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
connective.setFieldType( DataType.TYPE_STRING );
connective.setOperator( "|| ==" );
connective.setValue( "goo" );
X.setConnectives( new ConnectiveConstraint[ 1 ] );
X.getConnectives()[ 0 ] = connective;
final SingleFieldConstraint Y = new SingleFieldConstraint();
Y.setFieldName( "field2" );
Y.setFieldType( DataType.TYPE_STRING );
Y.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
Y.setValue( "$f2" );
Y.setOperator( "==" );
comp.addConstraint( Y );
String expected = "rule \"t1_0\"\n" +
"dialect \"mvel\"\n" +
"when\n" +
"Person( field1 == \"foo\" || == \"goo\" )\n" +
"then\n" +
"end\n";
m.addRow( new String[]{ "foo", null } );
checkMarshall( expected,
m );
}