RuleModel model = new RuleModel();
model.rhs = new IAction[2];
ActionInsertFact aif0 = new ActionInsertFact( "AIF0" );
aif0.setBoundName( "$t0" );
ActionFieldValue aif0f0 = new ActionFieldValue( "AIF0F0",
"AIF0F0Value",
SuggestionCompletionEngine.TYPE_STRING );
aif0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
aif0.addFieldValue( aif0f0 );
ActionFieldValue aif0f1 = new ActionFieldValue( "AIF0F1",
"AIF0F1Value",
SuggestionCompletionEngine.TYPE_STRING );
aif0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
aif0.addFieldValue( aif0f1 );
model.rhs[0] = aif0;
ActionInsertFact aif1 = new ActionInsertFact( "AIF1" );
aif1.setBoundName( "$t1" );
ActionFieldValue aif1f0 = new ActionFieldValue( "AIF1F0",
"AIF1F0Value",
SuggestionCompletionEngine.TYPE_STRING );
aif1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
aif1.addFieldValue( aif1f0 );
ActionFieldValue aif1f1 = new ActionFieldValue( "AIF1F1",
"AIF1F1Value",
SuggestionCompletionEngine.TYPE_STRING );
aif1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
aif1.addFieldValue( aif1f1 );
model.rhs[1] = aif1;
RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
RuleModel clone = cloneVisitor.visitRuleModel( model );
assertEquals( 2,
clone.rhs.length );
assertNotSame( model.rhs[0],
clone.rhs[0] );
assertNotNull( clone.rhs[0] );
assertTrue( clone.rhs[0] instanceof ActionInsertFact );
ActionInsertFact aif0Clone = (ActionInsertFact) clone.rhs[0];
assertEquals( "AIF0",
aif0Clone.factType );
assertEquals( "$t0",
aif0Clone.getBoundName() );
assertEquals( 2,
aif0Clone.fieldValues.length );
assertNotSame( aif0.fieldValues[0],
aif0Clone.fieldValues[0] );
assertNotNull( aif0Clone.fieldValues[0] );
assertTrue( aif0Clone.fieldValues[0] instanceof ActionFieldValue );
ActionFieldValue aif0f0Clone = (ActionFieldValue) aif0Clone.fieldValues[0];
assertEquals( aif0f0.field,
aif0f0Clone.field );
assertEquals( aif0f0.nature,
aif0f0Clone.nature );
assertEquals( aif0f0.type,
aif0f0Clone.type );
assertEquals( aif0f0.value,
aif0f0Clone.value );
assertNotSame( aif0.fieldValues[1],
aif0Clone.fieldValues[1] );
assertNotNull( aif0Clone.fieldValues[1] );
assertTrue( aif0Clone.fieldValues[1] instanceof ActionFieldValue );
ActionFieldValue aif0f1Clone = (ActionFieldValue) aif0Clone.fieldValues[1];
assertEquals( aif0f1.field,
aif0f1Clone.field );
assertEquals( aif0f1.nature,
aif0f1Clone.nature );
assertEquals( aif0f1.type,
aif0f1Clone.type );
assertEquals( aif0f1.value,
aif0f1Clone.value );
assertNotSame( model.rhs[1],
clone.rhs[1] );
assertNotNull( clone.rhs[1] );
assertTrue( clone.rhs[1] instanceof ActionInsertFact );
ActionInsertFact aif1Clone = (ActionInsertFact) clone.rhs[1];
assertEquals( "AIF1",
aif1Clone.factType );
assertEquals( "$t1",
aif1Clone.getBoundName() );
assertEquals( 2,
aif1Clone.fieldValues.length );
assertNotSame( aif1.fieldValues[0],
aif1Clone.fieldValues[0] );
assertNotNull( aif1Clone.fieldValues[0] );
assertTrue( aif1Clone.fieldValues[0] instanceof ActionFieldValue );
ActionFieldValue aif1f0Clone = (ActionFieldValue) aif1Clone.fieldValues[0];
assertEquals( aif1f0.field,
aif1f0Clone.field );
assertEquals( aif1f0.nature,
aif1f0Clone.nature );
assertEquals( aif1f0.type,
aif1f0Clone.type );
assertEquals( aif1f0.value,
aif1f0Clone.value );
assertNotSame( aif1.fieldValues[1],
aif1Clone.fieldValues[1] );
assertNotNull( aif1Clone.fieldValues[1] );
assertTrue( aif1Clone.fieldValues[1] instanceof ActionFieldValue );
ActionFieldValue aif1f1Clone = (ActionFieldValue) aif1Clone.fieldValues[1];
assertEquals( aif1f1.field,
aif1f1Clone.field );
assertEquals( aif1f1.nature,
aif1f1Clone.nature );
assertEquals( aif1f1.type,