}
@Test
public void testMetaData() {
final RuleModel m = new RuleModel();
final RuleMetadata rm = new RuleMetadata( "foo",
"bar" );
// test add
m.addMetadata( rm );
assertEquals( 1,
m.metadataList.length );
assertEquals( rm,
m.metadataList[0] );
// should be able to find it
RuleMetadata gm = m.getMetaData( "foo" );
assertNotNull( gm );
// test add and remove
final RuleMetadata rm2 = new RuleMetadata( "foo2",
"bar2" );
m.addMetadata( rm2 );
assertEquals( 2,
m.metadataList.length );
assertEquals( rm2,
m.metadataList[1] );
assertEquals( "@foo(bar)",
rm.toString() );
m.removeMetadata( 0 );
assertEquals( 1,
m.metadataList.length );
assertEquals( rm2,
m.metadataList[0] );
assertEquals( "@foo2(bar2)",
(m.metadataList[0]).toString() );
// should be able to find it now that it was removed
gm = m.getMetaData( "foo" );
assertNull( gm );
// test add via update method
m.updateMetadata( rm );
gm = m.getMetaData( "foo" );
assertNotNull( gm );
// test update of existing element
rm.setValue( "bar2" );
m.updateMetadata( rm );
gm = m.getMetaData( "foo" );
assertNotNull( gm );
assertEquals( "bar2",
gm.getValue() );
}