]
Mario Fusco updated DROOLS-5872:
--------------------------------
Sprint: 2020 Week 49-51 (from Nov 30)
DrlDumper generates wrong drl when AccumulateDescr does not have
constraint
---------------------------------------------------------------------------
Key: DROOLS-5872
URL:
https://issues.redhat.com/browse/DROOLS-5872
Project: Drools
Issue Type: Bug
Components: core engine
Affects Versions: 7.44.0.Final, 7.46.0.Final
Reporter: Hiroko Miura
Assignee: Mario Fusco
Priority: Major
Labels: support
Attachments: accumulate-without-constraint-test.zip
When AccumulateDescr does not have constraint, generated DRL can not be built.
Here is an example code.
{code:java}
PackageDescr packageDescr = DescrFactory.newPackage().name("example")
.newImport().target("java.math.BigDecimal").end()
.newRule().name("Test Rule")
.lhs()
.accumulate()
.source().pattern().type("example.RuleTest.Fact").id("$target",
false)
.end()
.end()
.function("count", "$cnt", false)
// adding the following constraint can avoid from KieBase build error
// .constraint("true")
.end()
.end()
.rhs("System.out.println($cnt);")
.end()
.end().getDescr();
String drl = new DrlDumper().dump(packageDescr);
{code}
This dumps the following DRL.
{code:java}
package example
import java.math.BigDecimal
rule "Test Rule"
when
accumulate(
$target : example.RuleTest.Fact( ) ,
$cnt : count( ) ;
)
then
System.out.println($cnt);
end
{code}
KieBase build with above drl fails with the following error.
{noformat}
2020-12-02 15:05:47,875 ERROR [org.drools.compiler.kie.builder.impl.KieProject] (main)
Unable to build KieBaseModel:defaultKieBase
[10,9]: [ERR 101] Line 10:9 no viable alternative at input ')' in rule "Test
Rule"
[0,0]: Parser returned a null Package
{noformat}
Adding constraint like comment line in above code can avoid from build error.