@Test
public void testDSLSentence() {
RuleModel model = new RuleModel();
model.lhs = new IPattern[2];
DSLSentence dsl0 = new DSLSentence();
dsl0.setDefinition( "DSL Sentence 0" );
dsl0.getValues().add( new DSLVariableValue( "dsl0v0" ) );
dsl0.getValues().add( new DSLVariableValue( "dsl0v1" ) );
model.lhs[0] = dsl0;
DSLSentence dsl1 = new DSLSentence();
dsl1.setDefinition( "DSL Sentence 1" );
dsl1.getValues().add( new DSLVariableValue( "dsl1v0" ) );
dsl1.getValues().add( new DSLVariableValue( "dsl1v1" ) );
model.lhs[1] = dsl1;
RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
RuleModel clone = cloneVisitor.visitRuleModel( model );
assertEquals( 2,
clone.lhs.length );
assertNotSame( model.lhs[0],
clone.lhs[0] );
assertNotNull( clone.lhs[0] );
assertTrue( clone.lhs[0] instanceof DSLSentence );
DSLSentence dsl0Clone = (DSLSentence) clone.lhs[0];
assertEquals( dsl0.getDefinition(),
dsl0Clone.getDefinition() );
assertEquals( 2,
dsl0Clone.getValues().size() );
assertNotSame( dsl0.getValues().get( 0 ),
dsl0Clone.getValues().get( 0 ) );
assertNotNull( dsl0Clone.getValues().get( 0 ) );
assertTrue( dsl0Clone.getValues().get( 0 ) instanceof DSLVariableValue );
DSLVariableValue dsl0v0Clone = (DSLVariableValue) dsl0Clone.getValues().get( 0 );
assertEquals( dsl0.getValues().get( 0 ).getValue(),
dsl0v0Clone.getValue() );
assertNotSame( dsl0.getValues().get( 1 ),
dsl0Clone.getValues().get( 1 ) );
assertNotNull( dsl0Clone.getValues().get( 1 ) );
assertTrue( dsl0Clone.getValues().get( 1 ) instanceof DSLVariableValue );
DSLVariableValue dsl0v1Clone = (DSLVariableValue) dsl0Clone.getValues().get( 1 );
assertEquals( dsl0.getValues().get( 1 ).getValue(),
dsl0v1Clone.getValue() );
assertNotSame( model.lhs[1],
clone.lhs[1] );
assertNotNull( clone.lhs[1] );
assertTrue( clone.lhs[1] instanceof DSLSentence );
DSLSentence dsl1Clone = (DSLSentence) clone.lhs[1];
assertEquals( dsl1.getDefinition(),
dsl1Clone.getDefinition() );
assertEquals( 2,
dsl1Clone.getValues().size() );
assertNotSame( dsl1.getValues().get( 0 ),
dsl0Clone.getValues().get( 0 ) );
assertNotNull( dsl1Clone.getValues().get( 0 ) );
assertTrue( dsl1Clone.getValues().get( 0 ) instanceof DSLVariableValue );
DSLVariableValue dsl1v0Clone = (DSLVariableValue) dsl1Clone.getValues().get( 0 );
assertEquals( dsl1.getValues().get( 0 ).getValue(),
dsl1v0Clone.getValue() );
assertNotSame( dsl1.getValues().get( 1 ),
dsl1Clone.getValues().get( 1 ) );
assertNotNull( dsl1Clone.getValues().get( 1 ) );
assertTrue( dsl1Clone.getValues().get( 1 ) instanceof DSLVariableValue );
DSLVariableValue dsl1v1Clone = (DSLVariableValue) dsl1Clone.getValues().get( 1 );
assertEquals( dsl1.getValues().get( 1 ).getValue(),
dsl1v1Clone.getValue() );
}