Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yurloc opened this issue May 13, 2024 · 2 comments
Closed

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

yurloc opened this issue May 13, 2024 · 2 comments
Assignees

Comments

@yurloc
Copy link
Contributor

yurloc commented May 13, 2024

Parent issue

Failing tests

  • org.drools.compiler.integrationtests.CepEspTest#testPropertyReactiveWithDurationOnRule
  • org.drools.compiler.integrationtests.TimerAndCalendarWithPseudoTimeTest#testNoProtocolIntervalTimer

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
Copy link
Contributor

/take

@tkobayas
Copy link
Contributor

Fixed by #5969

@github-project-automation github-project-automation bot moved this from 📋 Backlog to 🎯 Done in 🦉 KIE Podling Board May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎯 Done
Development

No branches or pull requests

2 participants