"sfc0p0Value" );
sfc0.setValue( "sfc0Value" );
fp0.addConstraint( sfc0 );
sfc0.addNewConnective();
ConnectiveConstraint sfc0cc0 = sfc0.connectives[0];
sfc0cc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
sfc0cc0.setFieldName( "sfc0" );
sfc0cc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
sfc0cc0.setOperator( "|| ==" );
sfc0cc0.setParameter( "sfc0cc0p0",
"sfc0cc0p0Value" );
sfc0cc0.setValue( "sfc0cc0Value" );
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 SingleFieldConstraint );
SingleFieldConstraint sfc0Clone = (SingleFieldConstraint) fp0Clone.constraintList.constraints[0];
assertEquals( sfc0.getConstraintValueType(),
sfc0Clone.getConstraintValueType() );
assertEquals( sfc0.getFieldBinding(),
sfc0Clone.getFieldBinding() );
assertEquals( sfc0.getFieldName(),
sfc0Clone.getFieldName() );
assertEquals( sfc0.getFieldType(),
sfc0Clone.getFieldType() );
assertEquals( sfc0.getOperator(),
sfc0Clone.getOperator() );
assertNotNull( sfc0Clone.getParameter( "sfc0p0" ) );
assertEquals( sfc0.getParameter( "sfc0p0" ),
sfc0Clone.getParameter( "sfc0p0" ) );
assertEquals( sfc0.getValue(),
sfc0Clone.getValue() );
assertEquals( sfc0.connectives.length,
sfc0Clone.connectives.length );
assertNotSame( sfc0.connectives[0],
sfc0Clone.connectives[0] );
assertNotNull( sfc0Clone.connectives[0] );
assertTrue( sfc0Clone.connectives[0] instanceof ConnectiveConstraint );
ConnectiveConstraint sfc0cc0Clone = (ConnectiveConstraint) sfc0Clone.connectives[0];
assertEquals( sfc0cc0.getConstraintValueType(),
sfc0cc0Clone.getConstraintValueType() );
assertEquals( sfc0cc0.getFieldName(),
sfc0cc0Clone.getFieldName() );
assertEquals( sfc0cc0.getFieldType(),
sfc0cc0Clone.getFieldType() );
assertEquals( sfc0cc0.getOperator(),
sfc0cc0Clone.getOperator() );
assertNotNull( sfc0cc0Clone.getParameter( "sfc0cc0p0" ) );
assertEquals( sfc0cc0.getParameter( "sfc0cc0p0" ),
sfc0cc0Clone.getParameter( "sfc0cc0p0" ) );
assertEquals( sfc0cc0.getValue(),
sfc0cc0Clone.getValue() );
}