tkobayas commented on code in PR #6791:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6791#discussion_r3504622218


##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/DeclaredTypesTest.java:
##########
@@ -599,6 +599,37 @@ public void testExtendPojo(RUN_TYPE runType) throws 
Exception {
         assertThat(ksession.fireAllRules()).isEqualTo(1);
     }
 
+    @ParameterizedTest
+    @MethodSource("parameters")
+    public void 
testResultConstraintReferencingInlineAccumulateBinding(RUN_TYPE runType) {
+        // An inline-binding accumulate whose result binding is used in a 
result constraint
+        // (e.g. "$ages : collectList($a); $ages.size > 0") must compile: the 
binding has to be typed
+        // against the accumulate function's result type rather than left as 
Object, otherwise the
+        // result-constraint lambda fails to compile.
+        String str =
+                "import " + Person.class.getCanonicalName() + ";\n" +
+                "import " + Result.class.getCanonicalName() + ";\n" +
+                "rule R when\n" +
+                "  accumulate(\n" +
+                "    $p : Person( $a : age );\n" +
+                "    $ages : collectList( $a );\n" +
+                "    $ages.size > 0\n" +
+                "  )\n" +
+                "then\n" +
+                "  insert(new Result($ages));\n" +
+                "end";
+        KieSession ksession = getKieSession(runType, str);
+
+        ksession.insert(new Person("Mark", 37));
+        ksession.insert(new Person("Mario", 40));
+
+        assertThat(ksession.fireAllRules()).isEqualTo(1);
+
+        Collection<Result> results = getObjectsIntoList(ksession, 
Result.class);
+        assertThat(results).hasSize(1);
+        assertThat((List) 
results.iterator().next().getValue()).containsExactlyInAnyOrder(37, 40);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to