-
Bug
-
Resolution: Done
-
Major
-
6.1.0.Final, 6.2.0.CR4
-
None
-
None
With reference to attached reproducer.
Assuming the following KB, where to goal is to keep a Counter fact for the amount of Measurement events received in the last hour.
declare Measurement @role(event) end rule "Init Counter last 1h" agenda-group "USERSPACE" salience 1 no-loop when not Counter( name == "Counter last 1h" ) then Counter c = new Counter("Counter last 1h", 0); insert(c); System.out.println("RHS Init Counter last 1h " + c); end rule "Update Counter last 1h" agenda-group "USERSPACE" no-loop when accumulate( $token : Measurement() over window:time( 1h ) ; $val : count($token) ) $cv1 : Counter( name == "Counter last 1h", value != $val.doubleValue() ) then int count = $val.intValue(); $cv1.setValue(count); update($cv1); System.out.println("RHS Update Counter last 1h : "+$cv1); end
The following Unit test shall have the effect in the end to obtain value 2.0 in the Counter object, as I've inserted 2 MEasurement within the last hour and within two minutes
advance(clock, 1, TimeUnit.MINUTES); insert(session, new Measurement("voltage", "220")); fire(session); advance(clock, 1, TimeUnit.MINUTES); insert(session, new Measurement("voltage", "221")); fire(session); LOG.info("Final checks"); Counter counter = (Counter) session.getObjects(counterFilter).iterator().next(); // I'm taking a shortcut as for this reproducer I know there is only 1 Counter in WM assertEquals("I've inserted 2 Measurement within the hour ", 2, counter.getValue(), 0);
However this works only with ReteOO and the test FAILS with Phreak.
Can you kindly advise, please?
Thank you
MM