model.lhs = new IPattern[1];
FactPattern fp0 = new FactPattern();
fp0.setBoundName( "$t0" );
fp0.setFactType( "FT0" );
CompositeFieldConstraint cfc0 = new CompositeFieldConstraint();
cfc0.compositeJunctionType = CompositeFieldConstraint.COMPOSITE_TYPE_OR;
SingleFieldConstraint sfc0 = new SingleFieldConstraint();
sfc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
sfc0.setFieldBinding( "$sfc0" );
sfc0.setFieldName( "sfc0" );
sfc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
sfc0.setOperator( "==" );
sfc0.setParameter( "sfc0p0",
"sfc0p0Value" );
sfc0.setValue( "sfc0Value" );
cfc0.addConstraint( sfc0 );
SingleFieldConstraint sfc1 = new SingleFieldConstraint();
sfc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
sfc1.setFieldBinding( "$sfc1" );
sfc1.setFieldName( "sfc1" );
sfc1.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
sfc1.setOperator( "==" );
sfc1.setParameter( "sfc1p0",
"sfc1p0Value" );
sfc1.setValue( "sfc1Value" );
cfc0.addConstraint( sfc1 );
fp0.addConstraint( cfc0 );
model.lhs[0] = fp0;
RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
RuleModel clone = cloneVisitor.visitRuleModel( model );
assertEquals( 1,
clone.lhs.length );
assertNotSame( model.lhs[0],
clone.lhs[0] );
assertNotNull( clone.lhs[0] );
assertTrue( clone.lhs[0] instanceof FactPattern );
FactPattern fp0Clone = (FactPattern) clone.lhs[0];
assertEquals( fp0.getBoundName(),
fp0Clone.getBoundName() );
assertEquals( fp0.getFactType(),
fp0Clone.getFactType() );
assertEquals( 1,
fp0Clone.constraintList.constraints.length );
assertNotSame( fp0.constraintList.constraints[0],
fp0Clone.constraintList.constraints[0] );
assertNotNull( fp0Clone.constraintList.constraints[0] );
assertTrue( fp0Clone.constraintList.constraints[0] instanceof CompositeFieldConstraint );
CompositeFieldConstraint cfc0Clone = (CompositeFieldConstraint) fp0Clone.constraintList.constraints[0];
assertEquals( cfc0.compositeJunctionType,
cfc0Clone.compositeJunctionType );
assertNotSame( cfc0.constraints[0],
cfc0Clone.constraints[0] );