I am trying to test the firing of a rule based on a cron timer using the pseudo clock in Drools Fusion 5.5. I want the rule to fire everyday at 1am:
rule "CALCULATING DATE FOR NEXT DAY"
timer (cron:00 00 01 * * ?)
no-loop
when
$summary: FxSummary(sameDayCcyFlag == false)
then
BusinessDayUtil b = new BusinessDayUtil();
modify($summary) {
setSettlementDate(b);
}
end
I then do the following in my test case:
PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();
DateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
Date date = df.parse( "2014-01-16T01:00:00.000-0000" );
Summary sum = new Summary("YEN").setSameDayCcyFlag(false);
ksession.fireAllRules();
timeService.advanceTime( date.getTime(), TimeUnit.MILLISECONDS );
ksession.fireAllRules();
It doesn't seem to do anything...no indication that the timer fired or anything. I've also tried to insert a date at say 12:59:50 and advanced the clock 10sec. Also, fireUntilHalt to have the engine running, etc. Nothing seems to work. Am I using this correctly? Does the pseudo clock work with timers? Also, does it fire "missed" timers if I advance the clock past a timer that was supposed to fire?