Search in sources :

Example 11 with Condition

use of org.drools.template.model.Condition in project drools by kiegroup.

the class RuleWorksheetParseTest method doComplexWorksheetMissingConditions.

private void doComplexWorksheetMissingConditions() throws IOException {
    final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/ComplexWorkbook.xls");
    final RuleSheetListener listener = getRuleSheetListener(stream);
    final Package ruleset = listener.getRuleSet();
    assertEquals(6, ruleset.getRules().size());
    assertEquals(0, ruleset.getImports().size());
    Rule rule = (Rule) ruleset.getRules().get(0);
    assertEquals(3, rule.getConditions().size());
    assertEquals(2, rule.getConsequences().size());
    final Consequence cons = (Consequence) rule.getConsequences().get(1);
    assertEquals("myObject.setIsValid(1, 2)", cons.getSnippet());
    final Condition con = (Condition) rule.getConditions().get(2);
    assertEquals("myObject.size() < $3.00", con.getSnippet());
    rule = (Rule) ruleset.getRules().get(4);
    // this should have less conditions
    assertEquals(1, rule.getConditions().size());
    rule = (Rule) ruleset.getRules().get(5);
    assertEquals(2, rule.getConditions().size());
    assertEquals(1, rule.getConsequences().size());
}
Also used : Condition(org.drools.template.model.Condition) InputStream(java.io.InputStream) Consequence(org.drools.template.model.Consequence) Package(org.drools.template.model.Package) Rule(org.drools.template.model.Rule)

Aggregations

Condition (org.drools.template.model.Condition)11 Rule (org.drools.template.model.Rule)6 InputStream (java.io.InputStream)5 Package (org.drools.template.model.Package)5 Test (org.junit.Test)4 Consequence (org.drools.template.model.Consequence)3 DRLOutput (org.drools.template.model.DRLOutput)3 SnippetBuilder (org.drools.template.model.SnippetBuilder)3 Import (org.drools.template.model.Import)1