//init stateful knowledge session
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession( sessionConfig, null );
ArrayList list = new ArrayList( );
ksession.setGlobal( "list", list );
SessionPseudoClock clock = (SessionPseudoClock) ksession.<SessionClock>getSessionClock();
ksession.setGlobal( "clock", clock );
ksession.insert( new Event( 1, -1, clock.getCurrentTime() ) ); // 0
clock.advanceTime(600, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
ksession.insert( new Event( 2, 0, clock.getCurrentTime() ) ); // 600
clock.advanceTime(100, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
ksession.insert( new Event( 2, 0, clock.getCurrentTime() ) ); // 700
clock.advanceTime(300, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
ksession.insert( new Event( 2, 0, clock.getCurrentTime() ) ); // 1000
clock.advanceTime(100, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
ksession.insert( new Event( 2, 1, clock.getCurrentTime() ) ); // 1100
clock.advanceTime(100, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
clock.advanceTime(100, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
ksession.insert( new Event( 2, 0, clock.getCurrentTime() ) ); // 1300
clock.advanceTime(1000, TimeUnit.MILLISECONDS);
ksession.fireAllRules();
assertFalse( list.isEmpty() );
assertEquals( 1, list.size() );
Long time = (Long) list.get( 0 );