lhs.getDescrs().size() );
//System.err.println( lhs.getDescrs() );
// Check first pattern
final PatternDescr first = (PatternDescr) lhs.getDescrs().get( 0 );
assertEquals( "foo3",
first.getIdentifier() );
assertEquals( "Bar",
first.getObjectType() );
assertEquals( 1,
first.getConstraint().getDescrs().size() );
//LiteralDescr constraint = (LiteralDescr) first.getDescrs().get( 0 );
AndDescr and = (AndDescr) first.getConstraint();
FieldConstraintDescr fld = (FieldConstraintDescr) and.getDescrs().get( 0 );
LiteralRestrictionDescr constraint = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
assertNotNull( constraint );
assertEquals( "a",
fld.getFieldName() );
assertEquals( "==",
constraint.getEvaluator() );
assertEquals( "3",
constraint.getText() );
// Check second pattern
final PatternDescr second = (PatternDescr) lhs.getDescrs().get( 1 );
assertEquals( "foo4",
second.getIdentifier() );
assertEquals( "Bar",
second.getObjectType() );
and = (AndDescr) second.getConstraint();
assertEquals( 2,
and.getDescrs().size() );
//System.err.println( second.getDescrs() );
final FieldBindingDescr fieldBindingDescr = (FieldBindingDescr) and.getDescrs().get( 0 );
assertEquals( "a",
fieldBindingDescr.getFieldName() );
assertEquals( "a4",
fieldBindingDescr.getIdentifier() );
fld = (FieldConstraintDescr) and.getDescrs().get( 1 );
constraint = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
assertNotNull( constraint );
assertEquals( "a",
fld.getFieldName() );
assertEquals( "==",
constraint.getEvaluator() );
assertEquals( "4",
constraint.getText() );
// Check third pattern
final PatternDescr third = (PatternDescr) lhs.getDescrs().get( 2 );
assertNull( third.getIdentifier() );
assertEquals( "Baz",
third.getObjectType() );
assertEqualsIgnoreWhitespace( "if ( a == b ) { " + " assert( foo3 );" + "} else {" + " retract( foo4 );" + "}" + " System.out.println( a4 );",
(String) rule.getConsequence() );
assertFalse( this.parser.hasErrors() );