" mfield0 : int = 200 //@position(0)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
FactType sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 5, sw.getFields().size() );
assertEquals( "field0", sw.getFields().get(0).getName() );
assertEquals( "field1", sw.getFields().get(1).getName() );
assertEquals( "mfield1", sw.getFields().get(2).getName() );
assertEquals( "field2", sw.getFields().get(3).getName() );
assertEquals( "mfield0", sw.getFields().get(4).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 //@position(0)\n" +
" field1 : int = 101 //@position(1)\n" +
" field2 : int = 102 //@position(0)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 @position(0)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 5, sw.getFields().size() );
assertEquals( "mfield0", sw.getFields().get(0).getName() );
assertEquals( "field0", sw.getFields().get(1).getName() );
assertEquals( "mfield1", sw.getFields().get(2).getName() );
assertEquals( "field1", sw.getFields().get(3).getName() );
assertEquals( "field2", sw.getFields().get(4).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 @position(0)\n" +
" field1 : int = 101 @position(1)\n" +
" field2 : int = 102 @position(0)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 //@position(0)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 5, sw.getFields().size() );
assertEquals( "field0", sw.getFields().get(0).getName() );
assertEquals( "field2", sw.getFields().get(1).getName() );
assertEquals( "field1", sw.getFields().get(2).getName() );
assertEquals( "mfield1", sw.getFields().get(3).getName() );
assertEquals( "mfield0", sw.getFields().get(4).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 @position(1)\n" +
" field1 : int = 101 @position(0)\n" +
" field2 : int = 102 @position(0)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 @position(0)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 5, sw.getFields().size() );
assertEquals( "field1", sw.getFields().get(0).getName() );
assertEquals( "field2", sw.getFields().get(1).getName() );
assertEquals( "mfield0", sw.getFields().get(2).getName() );
assertEquals( "field0", sw.getFields().get(3).getName() );
assertEquals( "mfield1", sw.getFields().get(4).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 @position(2)\n" +
" field1 : int = 101 @position(1)\n" +
" field2 : int = 102 @position(8)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 @position(7)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 5, sw.getFields().size() );
assertEquals( "field1", sw.getFields().get(0).getName() );
assertEquals( "field0", sw.getFields().get(1).getName() );
assertEquals( "mfield1", sw.getFields().get(2).getName() );
assertEquals( "mfield0", sw.getFields().get(3).getName() );
assertEquals( "field2", sw.getFields().get(4).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 //@position(0)\n" +
" field1 : int = 101 //@position(1)\n" +
" field2 : int = 102 //@position(0)\n" +
"end\n" +
"\n" +
"declare trait SecPosTrait\n" +
"@propertyReactive\n" +
" field3 : int = 100 //@position(0)\n" +
" field1 : int = 101 //@position(1)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait, SecPosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 //@position(0)\n" +
" mfield1 : int = 201 //@position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
sw = knowledgeBase.getFactType( "org.drools.test", "MultiInhPosTrait" );
assertEquals( 6, sw.getFields().size() );
assertEquals( "field0", sw.getFields().get(0).getName() );
assertEquals( "field1", sw.getFields().get(1).getName() );
assertEquals( "field2", sw.getFields().get(2).getName() );
assertEquals( "field3", sw.getFields().get(3).getName() );
assertEquals( "mfield0", sw.getFields().get(4).getName() );
assertEquals( "mfield1", sw.getFields().get(5).getName() );
drl =
"package org.drools.test\n" +
"declare trait PosTrait\n" +
"@propertyReactive\n" +
" field0 : int = 100 @position(0)\n" +
" field1 : int = 101 @position(1)\n" +
" field2 : int = 102 @position(0)\n" +
"end\n" +
"\n" +
"declare trait SecPosTrait\n" +
"@propertyReactive\n" +
" field3 : int = 100 @position(2)\n" +
" field1 : int = 101 //@position(1)\n" +
"end\n" +
"\n" +
"declare trait MultiInhPosTrait extends PosTrait, SecPosTrait\n" +
"@propertyReactive\n" +
" mfield0 : int = 200 @position(0)\n" +
" mfield1 : int = 201 @position(2)\n" +
"end";
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
kBuilder.add( new ByteArrayResource( drl.getBytes() ), ResourceType.DRL );
if ( kBuilder.hasErrors() ) {
System.err.println( kBuilder.getErrors() );
}
assertFalse( kBuilder.hasErrors() );