Beispiel #1
0
  @Test
  public void testRuleRender() {
    final Rule rule = new Rule("myrule", new Integer(42), 1);
    rule.setComment("rule comments");

    final Condition cond = new Condition();
    cond.setComment("cond comment");
    cond.setSnippet("cond snippet");
    rule.addCondition(cond);

    final Consequence cons = new Consequence();
    cons.setComment("cons comment");
    cons.setSnippet("cons snippet;");
    rule.addConsequence(cons);
    rule.addConsequence(cons);

    final DRLOutput out = new DRLOutput();
    rule.renderDRL(out);
    final String drl = out.getDRL();
    assertNotNull(drl);

    assertTrue(drl.indexOf("cond snippet") != -1);
    assertTrue(drl.indexOf("cons snippet") != -1);
    assertTrue(drl.indexOf("salience 42") != -1);
    assertTrue(drl.indexOf("salience 42") < drl.indexOf("when"));
    assertTrue(drl.indexOf("cond snippet") < drl.indexOf("then"));
    assertTrue(drl.indexOf("cons snippet;") > drl.indexOf("then"));
    assertTrue(drl.indexOf("rule") != -1);
    assertTrue(drl.indexOf("end") > drl.indexOf("rule "));
    assertTrue(drl.indexOf("//rule comments") > -1);
  }
Beispiel #2
0
  @Test
  public void testNotEscapeChars() {
    // bit of a legacy from the olde XML dayes of yesteryeare
    final Condition cond = new Condition();
    cond.setSnippet("a < b");
    final DRLOutput out = new DRLOutput();
    cond.renderDRL(out);

    assertTrue(out.toString().indexOf("a < b") != -1);
  }