conf.setOption( ClockTypeOption.get( "pseudo" ) );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession( conf, null );
ArrayList list = new ArrayList( );
ksession.setGlobal( "list", list );
SessionPseudoClock clock = ( SessionPseudoClock ) ksession.getSessionClock();
org.drools.runtime.rule.FactHandle handle;
clock.advanceTime( 1100, TimeUnit.MILLISECONDS );
StockTick tick = new StockTick( 0, "AAA", 1.0, 0 );
StockTick tock = new StockTick( 1, "BBB", 1.0, 2500 );
StockTick tack = new StockTick( 1, "CCC", 1.0, 2700 );
WorkingMemoryEntryPoint epa = ksession.getWorkingMemoryEntryPoint( "AAA" );
WorkingMemoryEntryPoint epb = ksession.getWorkingMemoryEntryPoint( "BBB" );
epa.insert( tick );
epb.insert( tock );
ksession.insert( tack );
handle = ksession.insert( "go1" );
ksession.fireAllRules();
System.out.println( "***** " + list + " *****");
assertEquals( Arrays.asList( 0L, 1L, 1L ), list );
list.clear();
ksession.retract( handle );
clock.advanceTime( 2550, TimeUnit.MILLISECONDS );
handle = ksession.insert( "go2" );
ksession.fireAllRules();
System.out.println( "***** " + list + " *****");
assertEquals( Arrays.asList( 0L, 0L, 1L ), list );
list.clear();
ksession.retract( handle );
clock.advanceTime( 500, TimeUnit.MILLISECONDS );
handle = ksession.insert( "go3" );
ksession.fireAllRules();
System.out.println( "***** " + list + " *****");
assertEquals( Arrays.asList( 0L, 0L, 0L ), list );