barList[i] = new Bar( String.valueOf( i ) );
}
Foo[] fooList = new Foo[4];
for ( int i = 0; i < fooList.length; i++ ) {
fooList[i] = new Foo( String.valueOf( i ), i == 3 ? barList[2] : barList[i] );
}
for ( Foo foo : fooList ) {
ksession.insert( foo );
}
//the NPE is caused by exactly this sequence. of course there are more sequences but this
//appears to be the most short one
int[] magicFoos = new int[]{3, 3, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 3, 3, 2, 2, 3, 1, 1};
int[] magicBars = new int[]{1, 2, 0, 1, 1, 0, 1, 2, 2, 1, 2, 0, 0, 2, 0, 2, 0, 0, 1};
//upon final rule firing an NPE will be thrown in org.drools.core.rule.Accumulate
for ( int i = 0; i < magicFoos.length; i++ ) {
Foo tehFoo = fooList[magicFoos[i]];
org.kie.api.runtime.rule.FactHandle fooFactHandle = ksession.getFactHandle( tehFoo );
tehFoo.setBar( barList[magicBars[i]] );
ksession.update( fooFactHandle, tehFoo );
ksession.fireAllRules();
}
ksession.dispose();
}