Skip to content

Commit

Permalink
[incubator-kie-drools#5710] [new-parser] Unable to resolve method (fr…
Browse files Browse the repository at this point in the history
…om new) in a query (apache#5795)
  • Loading branch information
tkobayas committed Oct 2, 2024
1 parent 88302e0 commit 5001305
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3755,4 +3755,19 @@ void lhsPatternAnnotation() {
assertThat(annotationDescr.getName()).isEqualTo("watch");
assertThat(annotationDescr.getSingleValueAsString()).isEqualTo("!*, age");
}

@Test
void fromNew() {
final String text = "package org.drools\n" +
"rule R1\n" +
"when\n" +
" $p : Person() from new Person(\"John\", 30)\n" +
"then\n" +
"end\n";
PackageDescr packageDescr = parser.parse(text);
RuleDescr ruleDescr = packageDescr.getRules().get(0);
PatternDescr patternDescr = (PatternDescr) ruleDescr.getLhs().getDescrs().get(0);
FromDescr fromDescr = (FromDescr) patternDescr.getSource();
assertThat(fromDescr.getDataSource().toString()).isEqualTo("new Person(\"John\", 30)");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public BehaviorDescr visitPatternFilter(DRLParser.PatternFilterContext ctx) {
@Override
public FromDescr visitFromExpression(DRLParser.FromExpressionContext ctx) {
FromDescr fromDescr = new FromDescr();
fromDescr.setDataSource(new MVELExprDescr(ctx.getText()));
fromDescr.setDataSource(new MVELExprDescr(getTextPreservingWhitespace(ctx)));
return fromDescr;
}

Expand Down

0 comments on commit 5001305

Please sign in to comment.