Esempio n. 1
0
  @Test
  public void testDateEffectiveExpires() {
    WorkingMemory wm = new KnowledgeBaseImpl("x", null).newStatefulSession();

    final RuleImpl rule = new RuleImpl("myrule");

    final Calendar past = Calendar.getInstance();
    past.setTimeInMillis(10);

    final Calendar future = Calendar.getInstance();
    future.setTimeInMillis(future.getTimeInMillis() + 100000000);

    rule.setDateEffective(past);
    rule.setDateExpires(future);

    assertTrue(rule.isEffective(null, new RuleTerminalNode(), wm));

    rule.setDateExpires(past);
    assertFalse(rule.isEffective(null, new RuleTerminalNode(), wm));

    rule.setDateExpires(future);
    rule.setDateEffective(future);

    assertFalse(rule.isEffective(null, new RuleTerminalNode(), wm));
  }
Esempio n. 2
0
  @Test
  public void testDateExpires() throws Exception {
    WorkingMemory wm = new KnowledgeBaseImpl("x", null).newStatefulSession();

    final RuleImpl rule = new RuleImpl("myrule");

    assertTrue(rule.isEffective(null, new RuleTerminalNode(), wm));

    final Calendar earlier = Calendar.getInstance();
    earlier.setTimeInMillis(10);

    rule.setDateExpires(earlier);

    assertFalse(rule.isEffective(null, new RuleTerminalNode(), wm));

    final Calendar later = Calendar.getInstance();
    later.setTimeInMillis(later.getTimeInMillis() + 100000000);

    rule.setDateExpires(later);
    assertTrue(rule.isEffective(null, new RuleTerminalNode(), wm));
  }