@Test public void testTimeMachine() { SessionConfiguration conf = SessionConfiguration.newInstance(); conf.setClockType(ClockType.PSEUDO_CLOCK); WorkingMemory wm = new KnowledgeBaseImpl("x", null).newStatefulSession(conf, null); final Calendar future = Calendar.getInstance(); ((PseudoClockScheduler) wm.getSessionClock()).setStartupTime(future.getTimeInMillis()); final RuleImpl rule = new RuleImpl("myrule"); rule.setEnabled(EnabledBoolean.ENABLED_TRUE); assertTrue(rule.isEffective(null, new RuleTerminalNode(), wm)); future.setTimeInMillis(future.getTimeInMillis() + 100000000); rule.setDateEffective(future); assertFalse(rule.isEffective(null, new RuleTerminalNode(), wm)); ((PseudoClockScheduler) wm.getSessionClock()) .advanceTime(1000000000000L, TimeUnit.MILLISECONDS); assertTrue(rule.isEffective(null, new RuleTerminalNode(), wm)); }
public KieSessionConfiguration newKnowledgeSessionConfiguration(Properties properties) { return SessionConfiguration.newInstance(properties); }
public KieSessionConfiguration newKnowledgeSessionConfiguration() { return SessionConfiguration.newInstance(); }