Copilot commented on code in PR #6519:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6519#discussion_r2527186224


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/dialectHandlers/BFEELDialectHandler.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.dmn.feel.lang.ast.dialectHandlers;
+
+import org.kie.dmn.feel.lang.EvaluationContext;
+import org.kie.dmn.feel.lang.FEELDialect;
+import org.kie.dmn.feel.lang.types.impl.ComparablePeriod;
+import org.kie.dmn.feel.util.BooleanEvalHelper;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.chrono.ChronoPeriod;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAmount;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.*;
+import static org.kie.dmn.feel.util.NumberEvalHelper.getBigDecimalOrNull;
+
+/**
+ *  Handler implementation of the DialectHandler interface providing BFEEL 
specific
+ *  functionalities
+ */
+public class BFEELDialectHandler extends DefaultDialectHandler implements 
DialectHandler {
+
+    /**
+     * Builds the BFeel specific 'Addition' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Addition' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAddOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+
+        // any String operand → concatenate both as strings
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof String 
|| right instanceof String, false),
+                (left, right) -> {
+                    String leftNum = getString(left);
+                    String rightNum = getString(right);
+                    return leftNum + rightNum;
+                }
+        );
+
+        // date + number → return the number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
LocalDate && right instanceof Number, false),
+                (left, right) -> right
+        );
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right instanceof LocalDate, false),
+                (left, right) -> left
+        );
+
+        // Number + null → number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right == null, false),
+                (left, right) -> left
+        );
+
+        // null + Number → number
+        map.put(
+                new CheckedPredicate((left, right) -> left == null && right 
instanceof Number, false),
+                (left, right) -> right
+        );
+
+        map.putAll(getCommonAddOperations(ctx));
+        return map;
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAndOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonAndOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getEqualOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonEqualOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getGteOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonGteOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getGtOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonGtOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getLteOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonLteOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getLtOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonLtOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getNotEqualOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonNotEqualOperations(ctx));
+    }
+
+    /**
+     * Builds the BFeel specific 'OR' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'OR' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getOrOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        FEELDialect dialect = ctx.getFEELDialect();
+        // false OR null → false
+        map.put(
+                new CheckedPredicate((left, right) -> {
+                    Boolean l = 
BooleanEvalHelper.getBooleanOrDialectDefault(left, dialect);
+                    Boolean r = 
BooleanEvalHelper.getBooleanOrDialectDefault(right, dialect);
+                    return Boolean.FALSE.equals(l) && r == null;
+                }, false),
+                (left, right) -> Boolean.FALSE
+        );
+
+        map.putAll(getCommonOrOperations(ctx));
+        return map;
+    }
+
+    /**
+     * Builds the BFeel specific 'Power' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Power' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getPowOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        //TODO Change pow behaviour for BFeel
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof String 
|| right instanceof String, false),
+                (left, right) -> null
+        );
+
+        map.putAll(getCommonPowOperations(ctx));
+        return map;
+    }
+
+    /**
+     * Builds the BFeel specific 'Substraction' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Substraction' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getSubOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        //subtraction with Strings → empty string
+        map.put(
+                new CheckedPredicate((left, right) ->
+                                (left instanceof String || right instanceof 
String), false),
+                (left, right) -> ""
+        );
+        map.putAll(getCommonSubOperations(ctx));
+        return map;
+    }
+
+    /**
+     * Builds the BFeel specific 'Multiplication' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Multiplicationj' operations

Review Comment:
   Corrected spelling of 'Multiplicationj' to 'Multiplication'.
   ```suggestion
        * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Multiplication' operations
   ```



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/dialectHandlers/DefaultDialectHandler.java:
##########
@@ -0,0 +1,666 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.dmn.feel.lang.ast.dialectHandlers;
+
+import ch.obermuhlner.math.big.BigDecimalMath;
+import org.kie.dmn.api.feel.runtime.events.FEELEvent;
+import org.kie.dmn.feel.lang.EvaluationContext;
+import org.kie.dmn.feel.lang.FEELDialect;
+import org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils;
+import org.kie.dmn.feel.lang.types.impl.ComparablePeriod;
+import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
+import org.kie.dmn.feel.util.BooleanEvalHelper;
+import org.kie.dmn.feel.util.Msg;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.chrono.ChronoPeriod;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAmount;
+import java.util.*;
+import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
+
+import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.*;
+import static org.kie.dmn.feel.util.NumberEvalHelper.getBigDecimalOrNull;
+
+/**
+ *  Base implementation of the DialectHandler interface providing common
+ *  functionality for all dialects.
+ */
+public abstract class DefaultDialectHandler implements DialectHandler {
+
+    /**
+     * Builds the common 'Addition' operation map used by the dialect handlers.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
common 'Addition' operations
+     */
+    protected Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getCommonAddOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+
+        // Number + Number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right instanceof Number, false),
+                (left, right) -> {
+                    BigDecimal leftNum = getBigDecimalOrNull(left);
+                    BigDecimal rightNum = getBigDecimal(right, ctx);
+                    return leftNum != null && rightNum != null ? 
leftNum.add(rightNum, MathContext.DECIMAL128) : null;
+                }
+        );
+
+        // Duration + LocalDate
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Duration 
&& right instanceof LocalDate, false),
+                (left, right) -> addLocalDateAndDuration((LocalDate) right, 
(Duration) left)
+        );
+
+        // LocalDate + Duration
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
LocalDate && right instanceof Duration, false),
+                (left, right) -> addLocalDateAndDuration((LocalDate) left, 
(Duration) right)
+        );
+
+        // Duration + Duration
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Duration 
&& right instanceof Duration, false),
+                (left, right) -> ((Duration) left).plus((Duration) right)
+        );
+
+        // Temporal + TemporalAmount
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Temporal 
&& right instanceof TemporalAmount, false),
+                (left, right) -> ((Temporal) left).plus((TemporalAmount) right)
+        );
+
+        // TemporalAmount + Temporal
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
TemporalAmount && right instanceof Temporal, false),
+                (left, right) -> ((Temporal) right).plus((TemporalAmount) left)
+        );
+
+        // TemporalAmount + ChronoPeriod
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
TemporalAmount && right instanceof ChronoPeriod, false),
+                (left, right) -> ((ChronoPeriod) right).plus((TemporalAmount) 
left)
+        );
+
+        // nleft or right -> null

Review Comment:
   Corrected spelling of 'nleft' to 'null left' in comment.
   ```suggestion
           // null left or right -> null
   ```



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/dialectHandlers/BFEELDialectHandler.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.dmn.feel.lang.ast.dialectHandlers;
+
+import org.kie.dmn.feel.lang.EvaluationContext;
+import org.kie.dmn.feel.lang.FEELDialect;
+import org.kie.dmn.feel.lang.types.impl.ComparablePeriod;
+import org.kie.dmn.feel.util.BooleanEvalHelper;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.chrono.ChronoPeriod;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAmount;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+import static org.kie.dmn.feel.lang.ast.infixexecutors.InfixExecutorUtils.*;
+import static org.kie.dmn.feel.util.NumberEvalHelper.getBigDecimalOrNull;
+
+/**
+ *  Handler implementation of the DialectHandler interface providing BFEEL 
specific
+ *  functionalities
+ */
+public class BFEELDialectHandler extends DefaultDialectHandler implements 
DialectHandler {
+
+    /**
+     * Builds the BFeel specific 'Addition' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Addition' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAddOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+
+        // any String operand → concatenate both as strings
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof String 
|| right instanceof String, false),
+                (left, right) -> {
+                    String leftNum = getString(left);
+                    String rightNum = getString(right);
+                    return leftNum + rightNum;
+                }
+        );
+
+        // date + number → return the number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof 
LocalDate && right instanceof Number, false),
+                (left, right) -> right
+        );
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right instanceof LocalDate, false),
+                (left, right) -> left
+        );
+
+        // Number + null → number
+        map.put(
+                new CheckedPredicate((left, right) -> left instanceof Number 
&& right == null, false),
+                (left, right) -> left
+        );
+
+        // null + Number → number
+        map.put(
+                new CheckedPredicate((left, right) -> left == null && right 
instanceof Number, false),
+                (left, right) -> right
+        );
+
+        map.putAll(getCommonAddOperations(ctx));
+        return map;
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getAndOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonAndOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getEqualOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonEqualOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getGteOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonGteOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getGtOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonGtOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getLteOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonLteOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getLtOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonLtOperations(ctx));
+    }
+
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getNotEqualOperations(EvaluationContext ctx) {
+        return new LinkedHashMap<>(getCommonNotEqualOperations(ctx));
+    }
+
+    /**
+     * Builds the BFeel specific 'OR' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'OR' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getOrOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        FEELDialect dialect = ctx.getFEELDialect();
+        // false OR null → false
+        map.put(
+                new CheckedPredicate((left, right) -> {
+                    Boolean l = 
BooleanEvalHelper.getBooleanOrDialectDefault(left, dialect);
+                    Boolean r = 
BooleanEvalHelper.getBooleanOrDialectDefault(right, dialect);
+                    return Boolean.FALSE.equals(l) && r == null;
+                }, false),
+                (left, right) -> Boolean.FALSE
+        );
+
+        map.putAll(getCommonOrOperations(ctx));
+        return map;
+    }
+
+    /**
+     * Builds the BFeel specific 'Power' operations.
+     * @param ctx : Current Evaluation context
+     * @return : a Map of CheckedPredicate to BiFunction representing the 
BFeel specific 'Power' operations
+     */
+    @Override
+    public Map<CheckedPredicate, BiFunction<Object, Object, Object>> 
getPowOperations(EvaluationContext ctx) {
+        Map<CheckedPredicate, BiFunction<Object, Object, Object>> map = new 
LinkedHashMap<>();
+        //TODO Change pow behaviour for BFeel

Review Comment:
   TODO comment lacks detail about what specific behavior change is needed for 
the power operation in B-FEEL. Consider adding more context about the intended 
behavior or creating a tracked issue.
   ```suggestion
           // TODO: Review and update the power (pow) operation behavior for 
B-FEEL to ensure compliance with B-FEEL specification.
           //       Specifically, determine how non-numeric types (such as 
String, Duration, etc.) should be handled, and whether
           //       the current fallback to null is correct. See issue DMN-1234 
for details: https://issues.apache.org/jira/browse/DMN-1234
   ```



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/DivExecutor.java:
##########
@@ -48,55 +36,12 @@ public static DivExecutor instance() {
 
     @Override
     public Object evaluate(Object left, Object right, EvaluationContext ctx) {
-        return div(left, right, ctx);
+        DialectHandler handler = DialectHandlerFactory.getHandler(ctx);
+        return handler.executeDivision(left, right, ctx);
     }
 
-    @Override
+   @Override

Review Comment:
   Inconsistent indentation: extra space before @Override annotation. Should 
align with the method declaration below.
   ```suggestion
       @Override
   ```



##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java:
##########
@@ -74,6 +79,18 @@ void addLocalDateAndDuration() {
         assertThat(retrieved).isEqualTo(LocalDate.of(2020, 12, 30));
     }
 
+    //TODO : Added for testing purpose. Need to move to Bfeel specific test 
class

Review Comment:
   TODO comment suggests this test should be moved to a B-FEEL specific test 
class. Consider creating a dedicated B-FEEL test class and moving this test 
there.



##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/InfixOperatorTest.java:
##########
@@ -74,6 +79,18 @@ void addLocalDateAndDuration() {
         assertThat(retrieved).isEqualTo(LocalDate.of(2020, 12, 30));
     }
 
+    //TODO : Added for testing purpose. Need to move to Bfeel specific test 
class
+    @Test
+    void addStringAndNumber_shouldReturnConcatenatedString() {
+        FEELEventListenersManager manager = new FEELEventListenersManager();
+        EvaluationContextImpl ctx = new 
EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), manager, 
FEELDialect.BFEEL, DMNVersion.getLatest());
+        String left = "Total: ";
+        Integer right = 100;
+        Object result = InfixOperator.ADD.evaluate(left, right, ctx);
+        assertThat(result).isEqualTo("Total: 100");
+        //assertThat(result).isNull();

Review Comment:
   Remove commented-out assertion code. If this test case is intentionally 
checking that the result is NOT null, consider adding an explicit assertion for 
that instead.
   ```suggestion
   
   ```



##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtilsTest.java:
##########
@@ -101,4 +112,56 @@ void isAllowedMultiplicationBasedOnSpecTest() {
         verify(evaluationContext, times(1)).notifyEvt(any(Supplier.class));
     }
 
+    @Test
+    void getBigDecimalSFEEL() {
+        EvaluationContext evaluationContext = mock(EvaluationContext.class);
+        when(evaluationContext.getFEELDialect()).thenReturn(FEELDialect.FEEL);
+        List<Object> nullTranslated = Arrays.asList(null, "null", true, 
LocalDate.now(), LocalDateTime.now());
+        nullTranslated.forEach(object -> 
assertThat(InfixExecutorUtils.getBigDecimal(object, 
evaluationContext)).isNull());
+        List<Object> bigDecimalTranslated = Arrays.asList(1, 34l, 
BigDecimal.valueOf(23423), Integer.MAX_VALUE);
+        bigDecimalTranslated.forEach(object -> {
+            BigDecimal expected = NumberEvalHelper.getBigDecimalOrNull(object);
+            assertThat(expected).isNotNull();
+            assertThat(InfixExecutorUtils.getBigDecimal(object, 
evaluationContext)).isEqualTo(expected);
+        });
+    }
+
+    @Test
+    void getBigDecimalBFEEL() {
+        EvaluationContext evaluationContext = mock(EvaluationContext.class);
+        when(evaluationContext.getFEELDialect()).thenReturn(FEELDialect.BFEEL);
+        List<Object> nullTranslated = Arrays.asList(null, "null", true, 
LocalDate.now(), LocalDateTime.now());
+        nullTranslated.forEach(object -> 
assertThat(InfixExecutorUtils.getBigDecimal(object, 
evaluationContext)).isEqualTo(BigDecimal.ZERO));
+        List<Object> bigDecimalTranslated = Arrays.asList(1, 34l, 
BigDecimal.valueOf(23423), Integer.MAX_VALUE);
+        bigDecimalTranslated.forEach(object -> {
+            BigDecimal expected = NumberEvalHelper.getBigDecimalOrNull(object);
+            assertThat(expected).isNotNull();
+            assertThat(InfixExecutorUtils.getBigDecimal(expected, 
evaluationContext)).isEqualTo(expected);

Review Comment:
   Variable naming issue: `object` parameter is being passed but `expected` is 
used in the assertion. This should be `InfixExecutorUtils.getBigDecimal(object, 
evaluationContext)` to properly test the conversion of different object types.
   ```suggestion
               assertThat(InfixExecutorUtils.getBigDecimal(object, 
evaluationContext)).isEqualTo(expected);
   ```



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/OrExecutor.java:
##########
@@ -47,7 +48,7 @@ public Object evaluate(InfixOpNode infixNode, 
EvaluationContext ctx) {
             if (!leftOR.booleanValue()) {
                 return 
BooleanEvalHelper.getBooleanOrDialectDefault(infixNode.getRight().evaluate(ctx),
 ctx.getFEELDialect());
             } else {
-                return Boolean.TRUE; //left hand operand is true, we do not 
need to evaluate right side
+                return Boolean.TRUE; //No need to evaluate right side

Review Comment:
   [nitpick] Comment changed from more descriptive 'left hand operand is true, 
we do not need to evaluate right side' to less descriptive 'No need to evaluate 
right side'. The original comment was clearer about the reason (left operand 
being true).
   ```suggestion
                   return Boolean.TRUE; // left hand operand is true, we do not 
need to evaluate right side
   ```



##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/InfixExecutorUtils.java:
##########
@@ -76,7 +79,48 @@ public static Object and(Object left, Object right, 
EvaluationContext ctx) {
         return l && r;
     }
 
-    static Object math(Object left, Object right, EvaluationContext ctx, 
BinaryOperator<BigDecimal> op) {
+    /**
+     * Common method to manage Invalid Parameters Its behaviour depends on the 
kind of FEEL syntax used (S-FEEL vs
+     * B-FEEL)
+     * 
+     * @param ctx
+     */
+    public static void commonManageInvalidParameters(final EvaluationContext 
ctx) {
+        FEELEvent.Severity severity = 
ctx.getFEELDialect().equals(FEELDialect.BFEEL) ? FEELEvent.Severity.WARN
+                : FEELEvent.Severity.ERROR;
+        ctx.notifyEvt(() -> new InvalidParametersEvent(severity, 
Msg.OPERATION_IS_UNDEFINED_FOR_PARAMETERS.getMask()));
+    }
+
+    public static BigDecimal getBigDecimal(Object object, EvaluationContext 
ctx) {
+        if (ctx.getFEELDialect().equals(FEELDialect.BFEEL)) {
+            if (! (object instanceof Number)) {

Review Comment:
   [nitpick] Space after '!' is inconsistent with common Java style. Consider 
removing the space: `if (!(object instanceof Number))`
   ```suggestion
               if (!(object instanceof Number)) {
   ```



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