From 60f5cb92b35d1fde156cd65dff8a06923d0d5c7b Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Tue, 10 Dec 2024 19:21:13 +0900 Subject: [PATCH] fixed assertion --- .../integrationtests/AccumulateTest.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java index 8b180f266dd..4213446b7b6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/AccumulateTest.java @@ -3954,15 +3954,13 @@ void minWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura " 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" + + " results.add($min.scale());\n" + // BigDecimal method "end"; final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession kieSession = kieBase.newKieSession(); try { - List results = new ArrayList<>(); + List results = new ArrayList<>(); kieSession.setGlobal("results", results); Primitives p1 = new Primitives(); p1.setBigDecimal(new BigDecimal("2024043020240501130000")); @@ -3975,8 +3973,9 @@ void minWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura kieSession.insert(p2_smallest); kieSession.insert(p3); kieSession.fireAllRules(); - assertThat(results).hasSize(1); + assertThat(results).hasSize(2); assertThat(results.get(0)).isEqualTo(p2_smallest.getBigDecimal()); + assertThat(results.get(1)).isEqualTo(0); } finally { kieSession.dispose(); } @@ -3992,15 +3991,13 @@ void minWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura " 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" + + " results.add($min.nextProbablePrime());\n" + // BigInteger method "end"; final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession kieSession = kieBase.newKieSession(); try { - List results = new ArrayList<>(); + List results = new ArrayList<>(); kieSession.setGlobal("results", results); Primitives p1 = new Primitives(); p1.setBigInteger(new BigInteger("2024043020240501130000")); @@ -4013,8 +4010,12 @@ void minWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura kieSession.insert(p2_smallest); kieSession.insert(p3); kieSession.fireAllRules(); - assertThat(results).hasSize(1); + assertThat(results).hasSize(2); assertThat(results.get(0)).isEqualTo(p2_smallest.getBigInteger()); + + // nextProbablePrime value is not important. + // Just to make sure it doesn't raise a compilation error. + assertThat(results.get(1)).isNotNull(); } finally { kieSession.dispose(); } @@ -4030,15 +4031,13 @@ void maxWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura " accumulate(Primitives($bd : bigDecimal), $max : max($bd))\n" + "then\n" + " results.add($max);\n" + - // to confirm if $max is BigDecimal at build time (Not Comparable) - // The return value isn't important to assert - " System.out.println($max.scale());\n" + + " results.add($max.scale());\n" + // BigDecimal method "end"; final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession kieSession = kieBase.newKieSession(); try { - List results = new ArrayList<>(); + List results = new ArrayList<>(); kieSession.setGlobal("results", results); Primitives p1 = new Primitives(); p1.setBigDecimal(new BigDecimal("2024043020240501130000")); @@ -4051,8 +4050,9 @@ void maxWithBigDecimalHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura kieSession.insert(p2_largest); kieSession.insert(p3); kieSession.fireAllRules(); - assertThat(results).hasSize(1); + assertThat(results).hasSize(2); assertThat(results.get(0)).isEqualTo(p2_largest.getBigDecimal()); + assertThat(results.get(1)).isEqualTo(0); } finally { kieSession.dispose(); } @@ -4068,15 +4068,13 @@ void maxWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura " accumulate(Primitives($bi : bigInteger), $max : max($bi))\n" + "then\n" + " results.add($max);\n" + - // to confirm if $max is BigInteger at build time (Not Comparable) - // The return value isn't important to assert - " System.out.println($max.nextProbablePrime());\n" + + " results.add($max.nextProbablePrime());\n" + // BigInteger method "end"; final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("accumulate-test", kieBaseTestConfiguration, drl); final KieSession kieSession = kieBase.newKieSession(); try { - List results = new ArrayList<>(); + List results = new ArrayList<>(); kieSession.setGlobal("results", results); Primitives p1 = new Primitives(); p1.setBigInteger(new BigInteger("2024043020240501130000")); @@ -4089,8 +4087,12 @@ void maxWithBigIntegerHighAccuracy(KieBaseTestConfiguration kieBaseTestConfigura kieSession.insert(p2_largest); kieSession.insert(p3); kieSession.fireAllRules(); - assertThat(results).hasSize(1); + assertThat(results).hasSize(2); assertThat(results.get(0)).isEqualTo(p2_largest.getBigInteger()); + + // nextProbablePrime value is not important. + // Just to make sure it doesn't raise a compilation error. + assertThat(results.get(1)).isNotNull(); } finally { kieSession.dispose(); }