m );
}
@Test
public void testSimpleFromCollectBothValues() {
TemplateModel m = new TemplateModel();
m.name = "r1";
FactPattern fp = new FactPattern( "Person" );
SingleFieldConstraint sfc = new SingleFieldConstraint( "field1" );
sfc.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
sfc.setFieldType( DataType.TYPE_STRING );
sfc.setOperator( "==" );
sfc.setValue( "$f1" );
fp.addConstraint( sfc );
FactPattern fp2 = new FactPattern( "java.util.List" );
SingleFieldConstraint sfc2 = new SingleFieldConstraint( "size" );
sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
sfc2.setFieldType( DataType.TYPE_NUMERIC_INTEGER );
sfc2.setOperator( ">" );
sfc2.setValue( "$f2" );
fp2.addConstraint( sfc2 );
FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
fac.setRightPattern( fp );
fac.setFactPattern( fp2 );
m.addLhsItem( fac );
String expected = "rule \"r1_0\"\n"
+ "dialect \"mvel\"\n"
+ "when\n"
+ "java.util.List( size > 1 ) from collect ( Person( field1 == \"foo\" ) ) \n"
+ "then\n"
+ "end";
m.addRow( new String[]{ "1", "foo" } );
checkMarshall( expected,
m );
}