public void testQuery() throws Exception {
final PackageBuilder builder = new PackageBuilder();
final PackageDescr packageDescr = new PackageDescr( "p1" );
final QueryDescr queryDescr = new QueryDescr( "query1" );
queryDescr.setParameters( new String[]{"$type"} );
queryDescr.setParameterTypes( new String[]{"String"} );
packageDescr.addRule( queryDescr );
final AndDescr lhs = new AndDescr();
queryDescr.setLhs( lhs );
final PatternDescr pattern = new PatternDescr( Cheese.class.getName(),
"stilton" );
lhs.addDescr( pattern );
final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
literalDescr.addRestriction( new VariableRestrictionDescr( "==",
"$type" ) );
pattern.addConstraint( literalDescr );
queryDescr.setConsequence( "update(stilton);" );
builder.addPackage( packageDescr );
assertLength( 0,
builder.getErrors().getErrors() );