diff --git a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/AddExecutor.java b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/AddExecutor.java index a7bb6c668d0..6eb78856b66 100644 --- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/AddExecutor.java +++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/infixexecutors/AddExecutor.java @@ -22,7 +22,6 @@ import java.math.MathContext; import java.time.Duration; import java.time.LocalDate; -import java.time.Period; import java.time.chrono.ChronoPeriod; import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; @@ -90,10 +89,6 @@ private Object add(Object left, Object right, EvaluationContext ctx) { if (right instanceof TemporalAmount temporalAmount) { return temporal.plus(temporalAmount); } - if (right instanceof BigDecimal bigDecimal) { - Period toAdd = Period.ofDays(bigDecimal.intValue()); - return temporal.plus(toAdd); - } } else if (left instanceof TemporalAmount temporalAmount) { if (right instanceof Temporal temporal) { return temporal.plus(temporalAmount); diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java index 3b7cb5b728e..2512b4294c7 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -48,7 +49,8 @@ private static Collection data() { final Object[][] cases = new Object[][] { //normal: {"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null}, - {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null}, + {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null}, + {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Arrays.asList(null, null, null), FEELEvent.Severity.ERROR}, //extended: {"for x in 1..3 return x+1", Stream.of(1, 2, 3).map(x -> BigDecimal.valueOf(x + 1)).collect(Collectors.toList()), null}, diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java index c22d69e572a..e011f32ba7a 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java @@ -51,6 +51,8 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity private static Collection data() { final Object[][] cases = new Object[][] { // date/time/duration function invocations + { "@\"2021-01-01\" + 10", null , FEELEvent.Severity.ERROR}, + { "@\"2021-01-01T10:10:10\" + 10", null , FEELEvent.Severity.ERROR}, { "date(\"2016-07-29\")", DateTimeFormatter.ISO_DATE.parse( "2016-07-29", LocalDate::from ) , null}, { "@\"2016-07-29\"", DateTimeFormatter.ISO_DATE.parse( "2016-07-29", LocalDate::from ) , null}, { "date(\"-0105-07-29\")", DateTimeFormatter.ISO_DATE.parse( "-0105-07-29", LocalDate::from ) , null}, // 105 BC diff --git a/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn index fe6ab52dfc2..a1509a0d0c5 100644 --- a/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn +++ b/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn @@ -40,7 +40,7 @@ - for x in @"2021-01-01"..@"2021-01-03" return x+1 + for x in @"2021-01-01"..@"2021-01-03" return x + duration("P1D")