ksconf.setOption( TimerJobFactoryOption.get("trackable") );
KieSession ksession = knowledgeBase.newStatefulKnowledgeSession( ksconf, null );
List list = new ArrayList();
ksession.setGlobal( "list", list );
SessionEntryPoint aep = ksession.getEntryPoint( "a-ep" );
aep.insert( new A() );
ksession = marsallStatefulKnowledgeSession( ksession );
SessionEntryPoint bep = ksession.getEntryPoint( "b-ep" );
bep.insert( new B() );
ksession = marsallStatefulKnowledgeSession( ksession );
SessionEntryPoint cep = ksession.getEntryPoint( "c-ep" );
cep.insert( new C() );
ksession = marsallStatefulKnowledgeSession( ksession );
ksession.fireAllRules();
ksession = marsallStatefulKnowledgeSession( ksession );
assertEquals( 3,
list.size() );
aep = ksession.getEntryPoint( "a-ep" );
assertEquals( 1, aep.getFactHandles().size() );
bep = ksession.getEntryPoint( "b-ep" );
assertEquals( 1, bep.getFactHandles().size() );
cep = ksession.getEntryPoint( "c-ep" );
assertEquals( 1, cep.getFactHandles().size() );
PseudoClockScheduler timeService = (PseudoClockScheduler) ksession.<SessionClock> getSessionClock();
timeService.advanceTime( 11, TimeUnit.SECONDS );
ksession = marsallStatefulKnowledgeSession( ksession );
ksession.fireAllRules();
ksession = marsallStatefulKnowledgeSession( ksession );
aep = ksession.getEntryPoint( "a-ep" );
assertEquals( 0, aep.getFactHandles().size() );
bep = ksession.getEntryPoint( "b-ep" );
assertEquals( 0, bep.getFactHandles().size() );
cep = ksession.getEntryPoint( "c-ep" );
assertEquals( 1, cep.getFactHandles().size() );
}