builder1.addPackage( packageDescr1 );
if ( builder1.hasErrors() ) {
fail( builder1.getErrors().toString() );
}
final Pattern pattern1 = (Pattern) ((RuleImpl)builder1.getPackage().getRules().iterator().next()).getLhs().getChildren().get( 0 );
final PredicateConstraint predicate1 = (PredicateConstraint) pattern1.getConstraints().get( 0 );
final KnowledgeBuilderImpl builder2 = new KnowledgeBuilderImpl();
final PackageDescr packageDescr2 = new PackageDescr( "package2" );
createPredicateRule( packageDescr2,
"eval(x==y)" );
builder2.addPackage( packageDescr2 );
if ( builder2.hasErrors() ) {
fail( builder2.getErrors().toString() );
}
final Pattern pattern2 = (Pattern) ((RuleImpl)builder2.getPackage().getRules().iterator().next()).getLhs().getChildren().get( 0 );
final PredicateConstraint predicate2 = (PredicateConstraint) pattern2.getConstraints().get( 0 );
final KnowledgeBuilderImpl builder3 = new KnowledgeBuilderImpl();
if ( builder3.hasErrors() ) {
fail( builder3.getErrors().toString() );
}
final PackageDescr packageDescr3 = new PackageDescr( "package3" );
createPredicateRule( packageDescr3,
"eval(x!=y)" );
builder3.addPackage( packageDescr3 );
final Pattern pattern3 = (Pattern) ((RuleImpl)builder3.getPackage().getRules().iterator().next()).getLhs().getChildren().get( 0 );
final PredicateConstraint predicate3 = (PredicateConstraint) pattern3.getConstraints().get( 0 );
assertEquals( predicate1,
predicate2 );
assertFalse( predicate1.equals( predicate3 ) );
assertFalse( predicate2.equals( predicate3 ) );