apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
5.85k stars 2.49k forks source link

[new-parser] Tests using wrong duration attribute format #5937

Closed yurloc closed 4 months ago

yurloc commented 4 months ago

Parent issue

Failing tests

Notes

I'm not 100% but it seems that these tests are wrong and the new parser is failing correctly. I've searched for occurrences in Drools code base and it seems that the following two alternative formats are allowed:

I think the reason why these tests do not fail with the old parser is that the old parser treats the expression inside parentheses as a "chunk" whereas the new parser goes into more detail so it is more sensitive.

Rule code snippet

rule Close
  duration (100)
when

and

rule xxx
  duration (30s 10s) 
when

Error output

### parse : ANTLR4_PARSER_ENABLED = true
line 1:189 mismatched input '100' expecting TIME_INTERVAL
18:31:19.927 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:KieBaseModelName
[1,189]: mismatched input '100' expecting TIME_INTERVAL
[0,0]: Parser returned a null Package

18:31:19.927 [main] ERROR o.d.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem:165 - KieBuilder errors: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=1, column=0
   text=mismatched input '100' expecting TIME_INTERVAL], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]

java.lang.AssertionError: [[Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=1, column=0
   text=mismatched input '100' expecting TIME_INTERVAL], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]] 
Expecting empty but was: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=1, column=0
   text=mismatched input '100' expecting TIME_INTERVAL],
    Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]

    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:169)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:134)
    at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:78)
    at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:72)
    at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:249)
    at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:238)
    at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromResources(KieBaseUtil.java:102)
    at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromDrl(KieBaseUtil.java:115)
    at org.drools.compiler.integrationtests.CepEspTest.testPropertyReactiveWithDurationOnRule(CepEspTest.java:5663)

and

### parse : ANTLR4_PARSER_ENABLED = true
line 4:16 extraneous input '10s' expecting ')'
18:31:52.373 [Time-limited test] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:KieBaseModelName
[4,16]: extraneous input '10s' expecting ')'
[0,0]: Parser returned a null Package

18:31:52.373 [Time-limited test] ERROR o.d.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem:165 - KieBuilder errors: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=extraneous input '10s' expecting ')'], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]

java.lang.AssertionError: [[Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=extraneous input '10s' expecting ')'], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]] 
Expecting empty but was: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=4, column=0
   text=extraneous input '10s' expecting ')'],
    Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=rules1.drl, line=0, column=0
   text=Parser returned a null Package]]

    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:169)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:134)
    at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:78)
    at org.drools.testcoverage.common.util.KieUtil.buildAndInstallKieModuleIntoRepo(KieUtil.java:72)
    at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:249)
    at org.drools.testcoverage.common.util.KieUtil.getKieModuleFromResources(KieUtil.java:238)
    at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromResources(KieBaseUtil.java:102)
    at org.drools.testcoverage.common.util.KieBaseUtil.getKieBaseFromKieModuleFromDrl(KieBaseUtil.java:115)
    at org.drools.compiler.integrationtests.TimerAndCalendarWithPseudoTimeTest.testIntervalTimer(TimerAndCalendarWithPseudoTimeTest.java:143)
    at org.drools.compiler.integrationtests.TimerAndCalendarWithPseudoTimeTest.testNoProtocolIntervalTimer(TimerAndCalendarWithPseudoTimeTest.java:123)
tkobayas commented 4 months ago

/take

tkobayas commented 4 months ago

Fixed by https://github.com/apache/incubator-kie-drools/pull/5969