pibizza commented on code in PR #6186:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6186#discussion_r1877702080


##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java:
##########
@@ -3941,4 +3943,156 @@ public void 
testPeerCollectWithEager(KieBaseTestConfiguration kieBaseTestConfigu
             kieSession.dispose();
         }
     }
+
+    @ParameterizedTest(name = "KieBase type={0}")
+    @MethodSource("parameters")
+    void minWithBigDecimalHighAccuracy(KieBaseTestConfiguration 
kieBaseTestConfiguration) {
+        final String drl =
+                "import " + Primitives.class.getCanonicalName() + ";\n" +
+                        "global java.util.List results;\n" +
+                        "rule R1 when\n" +
+                        "    accumulate(Primitives($bd : bigDecimal), $min : 
min($bd))\n" +
+                        "then\n" +
+                        "    results.add($min);\n" +
+                        // to confirm if $min is BigDecimal at build time (Not 
Comparable)
+                        // The return value isn't important to assert
+                        "    System.out.println($min.scale());\n" +
+                        "end";
+
+        final KieBase kieBase = 
KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", 
kieBaseTestConfiguration, drl);
+        final KieSession kieSession = kieBase.newKieSession();
+        try {
+            List<BigDecimal> results = new ArrayList<>();
+            kieSession.setGlobal("results", results);
+            Primitives p1 = new Primitives();
+            p1.setBigDecimal(new BigDecimal("2024043020240501130000"));
+            Primitives p2_smallest = new Primitives();
+            p2_smallest.setBigDecimal(new 
BigDecimal("2024043020240501120000"));
+            Primitives p3 = new Primitives();
+            p3.setBigDecimal(new BigDecimal("2024043020240501150000"));
+
+            kieSession.insert(p1);
+            kieSession.insert(p2_smallest);
+            kieSession.insert(p3);
+            kieSession.fireAllRules();
+            assertThat(results).hasSize(1);
+            assertThat(results.get(0)).isEqualTo(p2_smallest.getBigDecimal());
+        } finally {
+            kieSession.dispose();
+        }
+    }
+
+    @ParameterizedTest(name = "KieBase type={0}")
+    @MethodSource("parameters")
+    void minWithBigIntegerHighAccuracy(KieBaseTestConfiguration 
kieBaseTestConfiguration) {
+        final String drl =
+                "import " + Primitives.class.getCanonicalName() + ";\n" +
+                        "global java.util.List results;\n" +
+                        "rule R1 when\n" +
+                        "    accumulate(Primitives($bi : bigInteger), $min : 
min($bi))\n" +
+                        "then\n" +
+                        "    results.add($min);\n" +
+                        // to confirm if $min is BigInteger at build time (Not 
Comparable)
+                        // The return value isn't important to assert

Review Comment:
   Are these comments relevant? it seems that we are asserting the result 
values.



##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java:
##########
@@ -3941,4 +3943,156 @@ public void 
testPeerCollectWithEager(KieBaseTestConfiguration kieBaseTestConfigu
             kieSession.dispose();
         }
     }
+
+    @ParameterizedTest(name = "KieBase type={0}")
+    @MethodSource("parameters")
+    void minWithBigDecimalHighAccuracy(KieBaseTestConfiguration 
kieBaseTestConfiguration) {
+        final String drl =
+                "import " + Primitives.class.getCanonicalName() + ";\n" +
+                        "global java.util.List results;\n" +
+                        "rule R1 when\n" +
+                        "    accumulate(Primitives($bd : bigDecimal), $min : 
min($bd))\n" +
+                        "then\n" +
+                        "    results.add($min);\n" +
+                        // to confirm if $min is BigDecimal at build time (Not 
Comparable)
+                        // The return value isn't important to assert
+                        "    System.out.println($min.scale());\n" +
+                        "end";
+
+        final KieBase kieBase = 
KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", 
kieBaseTestConfiguration, drl);
+        final KieSession kieSession = kieBase.newKieSession();
+        try {
+            List<BigDecimal> results = new ArrayList<>();
+            kieSession.setGlobal("results", results);
+            Primitives p1 = new Primitives();
+            p1.setBigDecimal(new BigDecimal("2024043020240501130000"));
+            Primitives p2_smallest = new Primitives();
+            p2_smallest.setBigDecimal(new 
BigDecimal("2024043020240501120000"));
+            Primitives p3 = new Primitives();
+            p3.setBigDecimal(new BigDecimal("2024043020240501150000"));
+
+            kieSession.insert(p1);
+            kieSession.insert(p2_smallest);
+            kieSession.insert(p3);
+            kieSession.fireAllRules();
+            assertThat(results).hasSize(1);
+            assertThat(results.get(0)).isEqualTo(p2_smallest.getBigDecimal());
+        } finally {
+            kieSession.dispose();
+        }
+    }
+
+    @ParameterizedTest(name = "KieBase type={0}")
+    @MethodSource("parameters")
+    void minWithBigIntegerHighAccuracy(KieBaseTestConfiguration 
kieBaseTestConfiguration) {
+        final String drl =
+                "import " + Primitives.class.getCanonicalName() + ";\n" +
+                        "global java.util.List results;\n" +
+                        "rule R1 when\n" +
+                        "    accumulate(Primitives($bi : bigInteger), $min : 
min($bi))\n" +
+                        "then\n" +
+                        "    results.add($min);\n" +
+                        // to confirm if $min is BigInteger at build time (Not 
Comparable)
+                        // The return value isn't important to assert
+                        "    System.out.println($min.nextProbablePrime());\n" +

Review Comment:
   Do we need to printout this value? if possible a test should not print 
values, only check them in assertions.



-- 
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