This is an automated email from the ASF dual-hosted git repository.

tzimanyi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git


The following commit(s) were added to refs/heads/main by this push:
     new ff7e843420 [Incubator kie issues#1906] New version of date and time 
conversion function (#6303)
ff7e843420 is described below

commit ff7e8434206e32be452ae9557b8f4e3a80abaea0
Author: AthiraHari77 <[email protected]>
AuthorDate: Tue Jul 8 12:38:46 2025 +0530

    [Incubator kie issues#1906] New version of date and time conversion 
function (#6303)
---
 .../runtime/functions/DateAndTimeFunction.java     | 101 ++++++---
 .../runtime/functions/DateAndTimeFunctionTest.java | 225 ++++++++++++++++++++-
 .../runtime/functions/DateTimeFunctionTest.java    | 127 ------------
 3 files changed, 295 insertions(+), 158 deletions(-)

diff --git 
a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java
 
b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java
index 7570c3cd74..f648035e89 100644
--- 
a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java
+++ 
b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunction.java
@@ -62,10 +62,70 @@ public class DateAndTimeFunction
                                                                  
.toFormatter();
     }
 
+
     private DateAndTimeFunction() {
         super(FEELConversionFunctionNames.DATE_AND_TIME);
     }
 
+    static TemporalAccessor getValidDate(TemporalAccessor date) {
+        if (date == null) {
+            throw new IllegalArgumentException("Parameter 'date' is missing or 
invalid.");
+        }
+        if (date instanceof LocalDate) {
+            return date;
+        }
+        // FEEL Spec Table 58 "date is a date or date time [...] creates a 
date time from the given date (ignoring any time component)" [that means 
ignoring any TZ from `date` parameter, too]
+        // I try to convert `date` to a LocalDate, if the query method returns 
null would signify conversion is not possible.
+        date = date.query(TemporalQueries.localDate());
+        if (date != null) {
+            return date;
+        }
+        throw new IllegalArgumentException("Parameter 'date' is missing or 
invalid.");
+    }
+
+    static TemporalAccessor getValidTime(TemporalAccessor time) {
+        if (time == null || !(time instanceof LocalTime || 
(time.query(TemporalQueries.localTime()) != null && 
time.query(TemporalQueries.zone()) != null))) {
+            throw new IllegalArgumentException("Parameter 'time' is missing or 
invalid.");
+        }
+        return time;
+    }
+
+    static ZoneId getValidTimeZone(String timeZone) {
+        if (timeZone == null || timeZone.isEmpty()) {
+            throw new IllegalArgumentException("Parameter 'timezone' is 
missing or invalid.");
+        }
+        try {
+            return ZoneId.of(timeZone);
+        } catch (DateTimeException ex) {
+            throw new IllegalArgumentException("Parameter 'timezone' is 
missing or invalid.");
+        }
+    }
+
+    static FEELFnResult<TemporalAccessor> 
generateDateTimeAndTimezone(TemporalAccessor date, TemporalAccessor time, 
ZoneId zoneId) {
+        try {
+            TemporalAccessor validatedDate = getValidDate(date);
+            TemporalAccessor validatedTime = getValidTime(time);
+            if (validatedDate instanceof LocalDate && validatedTime instanceof 
LocalTime) {
+                if (zoneId != null) {
+                    return FEELFnResult.ofResult(ZonedDateTime.of((LocalDate) 
validatedDate, (LocalTime) validatedTime, zoneId));
+                } else {
+                    return FEELFnResult.ofResult(LocalDateTime.of((LocalDate) 
validatedDate, (LocalTime) validatedTime));
+                }
+            } else if (validatedDate instanceof LocalDate && 
time.query(TemporalQueries.localTime()) != null && 
time.query(TemporalQueries.zone()) != null) {
+                return FEELFnResult.ofResult(ZonedDateTime.of((LocalDate) 
validatedDate, LocalTime.from(validatedTime), zoneId != null ? zoneId : 
ZoneId.from(validatedTime)));
+            }
+            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "cannot invoke function for the input 
parameters"));
+        } catch (IllegalArgumentException e) {
+            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "Invalid Input", e.getMessage()));
+        } catch (DateTimeException e) {
+            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "input parameters date-parsing 
exception", e));
+        }
+    }
+
+    static FEELFnResult<TemporalAccessor> 
generateDateTimeAndTimezone(TemporalAccessor date, TemporalAccessor time) {
+        return generateDateTimeAndTimezone(date, time, null);
+    }
+
     public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "from" ) 
String val) {
         if ( val == null ) {
             return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "from", "cannot be null"));
@@ -86,36 +146,8 @@ public class DateAndTimeFunction
         }
     }
 
-    public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "date" ) 
TemporalAccessor date, @ParameterName( "time" ) TemporalAccessor time) {
-        if ( date == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "date", "cannot be null"));
-        }
-        if ( !(date instanceof LocalDate) ) {
-            // FEEL Spec Table 58 "date is a date or date time [...] creates a 
date time from the given date (ignoring any time component)" [that means 
ignoring any TZ from `date` parameter, too]
-            // I try to convert `date` to a LocalDate, if the query method 
returns null would signify conversion is not possible.
-            date = date.query(TemporalQueries.localDate());
-
-            if (date == null) {
-                return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "date", "must be an instance of 
LocalDate (or must be possible to convert to a FEEL date using built-in 
date(date) )"));
-            }
-        }
-        if ( time == null ) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "time", "cannot be null"));
-        }
-        if (!(time instanceof LocalTime || 
(time.query(TemporalQueries.localTime()) != null && 
time.query(TemporalQueries.zone()) != null))) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "time", "must be an instance of 
LocalTime or (it must contain localTime AND zone)"));
-        }
-
-        try {
-            if( date instanceof LocalDate && time instanceof LocalTime ) {
-                return FEELFnResult.ofResult( LocalDateTime.of( (LocalDate) 
date, (LocalTime) time ) );
-            } else if (date instanceof LocalDate && 
(time.query(TemporalQueries.localTime()) != null && 
time.query(TemporalQueries.zone()) != null)) {
-                return FEELFnResult.ofResult(ZonedDateTime.of((LocalDate) 
date, LocalTime.from(time), ZoneId.from(time)));
-            }
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "cannot invoke function for the input 
parameters"));
-        } catch (DateTimeException e) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "input parameters date-parsing 
exception", e));
-        }
+    public FEELFnResult<TemporalAccessor> invoke(@ParameterName("date") 
TemporalAccessor date, @ParameterName("time") TemporalAccessor time) {
+        return generateDateTimeAndTimezone(date, time);
     }
 
     public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "year" ) 
Number year, @ParameterName( "month" ) Number month, @ParameterName( "day" ) 
Number day,
@@ -174,6 +206,15 @@ public class DateAndTimeFunction
         } catch (DateTimeException e) {
             return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "input parameters date-parsing 
exception", e));
         }
+    }
 
+    public FEELFnResult<TemporalAccessor> invoke(@ParameterName("date") 
TemporalAccessor date, @ParameterName("time") TemporalAccessor time, 
@ParameterName("timeZone") String timeZone) {
+        try {
+            ZoneId zoneId = getValidTimeZone(timeZone);
+            return generateDateTimeAndTimezone(date, time, zoneId);
+        } catch (IllegalArgumentException e) {
+            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "Invalid Input", e.getMessage()));
+        }
     }
+
 }
diff --git 
a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunctionTest.java
 
b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunctionTest.java
index d271b324fa..081394b15b 100644
--- 
a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunctionTest.java
+++ 
b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateAndTimeFunctionTest.java
@@ -19,11 +19,23 @@
 package org.kie.dmn.feel.runtime.functions;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static 
org.kie.dmn.feel.runtime.functions.FunctionTestUtil.assertResultError;
+import static org.kie.dmn.feel.runtime.functions.FunctionTestUtil.assertResult;
 
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetTime;
 import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
+import java.time.temporal.Temporal;
 import java.time.temporal.TemporalAccessor;
+import java.util.NoSuchElementException;
 import org.junit.jupiter.api.Test;
+import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
 
 class DateAndTimeFunctionTest {
 
@@ -45,4 +57,215 @@ class DateAndTimeFunctionTest {
         assertThat(retrievedZonedDateTime.getSecond()).isZero();
         
assertThat(retrievedZonedDateTime.getZone()).isEqualTo(ZoneId.of("Europe/Paris"));
     }
-}
+
+    @Test
+    void invokeParamStringNull() {
+        assertResultError(dateTimeFunction.invoke(null), 
InvalidParametersEvent.class);
+    }
+
+    @Test
+    void invokeParamStringNotDateOrTime() {
+        assertResultError(dateTimeFunction.invoke("test"), 
InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke("2017-09-test"), 
InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke("2017-09-T89"), 
InvalidParametersEvent.class);
+    }
+
+    @Test
+    void invokeParamStringDateTime() {
+        assertResult(dateTimeFunction.invoke("2017-09-07T10:20:30"), 
LocalDateTime.of(2017, 9, 7, 10
+                , 20, 30));
+        assertResult(dateTimeFunction.invoke("99999-12-31T11:22:33"), 
LocalDateTime.of(99999, 12, 31
+                , 11, 22, 33));
+    }
+
+    @Test
+    void invokeParamStringDateTimeZoned() {
+        
assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30@Europe/Paris"),
+                ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 0, 
ZoneId.of("Europe/Paris")));
+        
assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.987@Europe/Paris"),
+                ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 987_000_000, 
ZoneId.of("Europe/Paris"
+                )));
+        
assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.123456789@Europe/Paris"),
+                ZonedDateTime.of(2011, 12, 31, 10, 15, 30, 123_456_789, 
ZoneId.of("Europe/Paris"
+                )));
+        
assertResult(dateTimeFunction.invoke("999999999-12-31T23:59:59.999999999@Europe/Paris"),
+                ZonedDateTime.of(999999999, 12, 31, 23, 59, 59, 999_999_999, 
ZoneId.of("Europe/Paris")));
+    }
+
+    @Test
+    void invokeParamStringDateOffset() {
+        
assertResult(dateTimeFunction.invoke("2017-12-31T23:59:59.999999999+02:00"),
+                ZonedDateTime.of(2017, 12, 31, 23, 59, 59, 999_999_999, 
ZoneOffset.of("+02:00")));
+        
assertResult(dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"),
+                ZonedDateTime.of(-999999999, 12, 31, 23, 59, 59, 999_999_999, 
ZoneOffset.of(
+                        "+02:00")));
+    }
+
+    @Test
+    void invokeParamStringDate() {
+        assertResult(dateTimeFunction.invoke("2017-09-07"), 
LocalDateTime.of(2017, 9, 7, 0, 0, 0));
+    }
+
+    @Test
+    void invokeParamTemporalNulls() {
+        assertResultError(dateTimeFunction.invoke((Temporal) null, null),
+                InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(null, LocalTime.of(10, 6, 
20)),
+                InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(LocalDate.of(2017, 6, 12), 
null),
+                InvalidParametersEvent.class);
+    }
+
+    @Test
+    void invokeParamTemporalWrongTemporal() {
+        // reminder: 1st parameter accordingly to FEEL Spec Table 58 "date is 
a date or date time [...] creates a
+        // date time from the given date (ignoring any time component)" [that 
means ignoring any TZ from `date`
+        // parameter, too]
+        assertResultError(dateTimeFunction.invoke(
+                        LocalDate.of(2017, 6, 12),
+                        LocalDateTime.of(2017, 6, 12, 0, 0)), 
InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(
+                        LocalDateTime.of(2017, 6, 12, 0, 0),
+                        LocalDateTime.of(2017, 6, 12, 0, 0)), 
InvalidParametersEvent.class);
+    }
+
+    @Test
+    void invokeParamTemporalLocalTime() {
+        assertResult(dateTimeFunction.invoke(
+                        LocalDate.of(2017, 6, 12),
+                        LocalTime.of(10, 6, 20)),
+                LocalDateTime.of(2017, 6, 12, 10, 6, 20));
+    }
+
+    @Test
+    void invokeParamTemporalOffsetTime() {
+        assertResult(dateTimeFunction.invoke(
+                        LocalDate.of(2017, 6, 12),
+                        OffsetTime.of(10, 6, 20, 0, ZoneOffset.UTC)),
+                ZonedDateTime.of(2017, 6, 12, 10, 6, 20, 0, ZoneOffset.UTC));
+    }
+
+    @Test
+    void invokeParamStringDateTimeZone() {
+        assertResult(dateTimeFunction.invoke(LocalDate.of(2024, 12, 24),
+                        LocalTime.of(23, 59, 0), "America/Costa_Rica"),
+                ZonedDateTime.of(2024, 12, 24, 23, 59, 0, 0, 
ZoneId.of("America/Costa_Rica")));
+        FEELFnResult<TemporalAccessor> expectedResult = 
dateTimeFunction.invoke(LocalDate.of(2024, 12, 24), LocalTime.of(23, 59, 0), 
"America/Costa_Rica");
+        assertThat(expectedResult.isRight()).isTrue();
+        assertThat(expectedResult.getOrElse(null)).isNotNull();
+        FEELFnResult<TemporalAccessor> retrievedResult = 
dateTimeFunction.invoke("2024-12-24T23:59:00@America/Costa_Rica");
+        assertThat(retrievedResult.isRight()).isTrue();
+        assertThat(retrievedResult.getOrElse(null)).isNotNull();
+        
assertThat(expectedResult.getOrElse(null)).isEqualTo(retrievedResult.getOrElse(null));
+    }
+
+    @Test
+    void testParamStringDateTimeZone() {
+        FEELFnResult<TemporalAccessor> result = 
dateTimeFunction.invoke(LocalDate.of(2024, 12, 24), LocalTime.of(23, 59, 0), 
"Z");
+        assertThat(result.isRight()).isTrue();
+        assertThat(result.getOrElse(null)).isNotNull();
+        ZonedDateTime actualDateTime = (ZonedDateTime) result.getOrElse(null);
+        ZonedDateTime expectedDateTime = ZonedDateTime.of(2024, 12, 24, 23, 
59, 0, 0, ZoneOffset.UTC);
+        assertThat(expectedDateTime).isEqualTo(actualDateTime);
+        FEELFnResult<TemporalAccessor> retrievedResult = 
dateTimeFunction.invoke("2024-12-24T23:59:00Z");
+        assertThat(retrievedResult.isRight()).isTrue();
+        assertThat(retrievedResult.getOrElse(null)).isNotNull();
+        assertThat(actualDateTime).isEqualTo(retrievedResult.getOrElse(null));
+    }
+
+    @Test
+    void testInvalidDateTimeAndTimezone() {
+        assertResultError(dateTimeFunction.invoke(null, LocalTime.of(23, 59, 
0), "Z"), InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(LocalDate.of(2024, 12, 24), 
null, "Z"), InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(LocalDate.of(2024, 12, 24), 
LocalTime.of(23, 59, 0), null), InvalidParametersEvent.class);
+        assertResultError(dateTimeFunction.invoke(LocalDate.of(2024, 12, 24), 
LocalTime.of(23, 59, 0), "Foo/Bar"), InvalidParametersEvent.class);
+    }
+
+    @Test
+    void testValidateDate() {
+        LocalDate date = LocalDate.of(2023, 6, 23);
+        TemporalAccessor result = DateAndTimeFunction.getValidDate(date);
+        assertThat(result).isNotNull();
+        assertThat(result).isEqualTo(date);
+    }
+
+    @Test
+    void testValidateTime() {
+        LocalTime time = LocalTime.of(23, 59, 0, 0);
+        TemporalAccessor result = DateAndTimeFunction.getValidTime(time);
+        assertThat(result).isNotNull();
+        assertThat(result).isEqualTo(time);
+    }
+
+    @Test
+    void testValidateTimeZone() {
+        String timeZone = "Europe/Paris";
+        ZoneId result = DateAndTimeFunction.getValidTimeZone(timeZone);
+
+        assertThat(result).isNotNull();
+        assertThat(result).isEqualTo(ZoneId.of("Europe/Paris"));
+    }
+
+    @Test
+    void testValidateNullDate() {
+        assertThatThrownBy(() -> DateAndTimeFunction.getValidDate(null))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'date' is 
missing or invalid.");
+    }
+
+    @Test
+    void testValidateNullTime() {
+        assertThatThrownBy(() -> DateAndTimeFunction.getValidTime(null))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'time' is 
missing or invalid.");
+    }
+
+    @Test
+    void testValidateNullTimeZone() {
+        assertThatThrownBy(() -> DateAndTimeFunction.getValidTimeZone(null))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'timezone' 
is missing or invalid.");
+    }
+
+    @Test
+    void testInvalidDate() {
+        assertThatThrownBy(() -> 
DateAndTimeFunction.getValidDate(DayOfWeek.MONDAY))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'date' is 
missing or invalid.");
+    }
+
+    @Test
+    void testInvalidTime() {
+        assertThatThrownBy(() -> 
DateAndTimeFunction.getValidTime(DayOfWeek.MONDAY))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'time' is 
missing or invalid.");
+    }
+
+    @Test
+    void testInvalidTimeZone() {
+        assertThatThrownBy(() -> 
DateAndTimeFunction.getValidTimeZone("Foo/Bar"))
+                
.isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'timezone' 
is missing or invalid.");
+    }
+
+    @Test
+    void testGenerateDateTimeAndTimeZone() {
+        
assertResult(DateAndTimeFunction.generateDateTimeAndTimezone(LocalDate.of(2024, 
12, 24),
+                        LocalTime.of(23, 59, 0), 
ZoneId.of("America/Costa_Rica")),
+                ZonedDateTime.of(2024, 12, 24, 23, 59, 0, 0, 
ZoneId.of("America/Costa_Rica")));
+    }
+
+    @Test
+    void testGenerateDateTimeOnly() {
+        
assertResult(DateAndTimeFunction.generateDateTimeAndTimezone(LocalDate.of(2017, 
6, 12),
+                        OffsetTime.of(10, 6, 20, 0, ZoneOffset.UTC), null),
+                ZonedDateTime.of(2017, 6, 12, 10, 6, 20, 0, ZoneOffset.UTC));
+    }
+
+    @Test
+    void testGenerateDateAndTime() {
+        
assertResult(DateAndTimeFunction.generateDateTimeAndTimezone(LocalDate.of(2024, 
12, 24),
+                        LocalTime.of(23, 59, 0), null),
+                LocalDateTime.of(2024, 12, 24, 23, 59, 0, 0));
+    }
+
+    @Test
+    void testInvalidDateTime() {
+        
assertResultError(DateAndTimeFunction.generateDateTimeAndTimezone(null,null, 
ZoneId.of("America/Costa_Rica")), InvalidParametersEvent.class);
+    }
+
+}
\ No newline at end of file
diff --git 
a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java
 
b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java
deleted file mode 100644
index 8576290f46..0000000000
--- 
a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/DateTimeFunctionTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.runtime.functions;
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.OffsetTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.temporal.Temporal;
-
-import org.junit.jupiter.api.Test;
-import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
-
-class DateTimeFunctionTest {
-
-    private static final DateAndTimeFunction dateTimeFunction = 
DateAndTimeFunction.INSTANCE;
-
-    @Test
-    void invokeParamStringNull() {
-        FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null), 
InvalidParametersEvent.class);
-    }
-
-    @Test
-    void invokeParamStringNotDateOrTime() {
-        FunctionTestUtil.assertResultError(dateTimeFunction.invoke("test"), 
InvalidParametersEvent.class);
-        
FunctionTestUtil.assertResultError(dateTimeFunction.invoke("2017-09-test"), 
InvalidParametersEvent.class);
-        
FunctionTestUtil.assertResultError(dateTimeFunction.invoke("2017-09-T89"), 
InvalidParametersEvent.class);
-    }
-
-    @Test
-    void invokeParamStringDateTime() {
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07T10:20:30"), 
LocalDateTime.of(2017, 9, 7, 10
-                , 20, 30));
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("99999-12-31T11:22:33"), 
LocalDateTime.of(99999, 12, 31
-                , 11, 22, 33));
-    }
-
-    @Test
-    void invokeParamStringDateTimeZoned() {
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30@Europe/Paris"),
-                                      ZonedDateTime.of(2011, 12, 31, 10, 15, 
30, 0, ZoneId.of("Europe/Paris")));
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.987@Europe/Paris"),
-                                      ZonedDateTime.of(2011, 12, 31, 10, 15, 
30, 987_000_000, ZoneId.of("Europe/Paris"
-                                      )));
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("2011-12-31T10:15:30.123456789@Europe/Paris"),
-                                      ZonedDateTime.of(2011, 12, 31, 10, 15, 
30, 123_456_789, ZoneId.of("Europe/Paris"
-                                      )));
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("999999999-12-31T23:59:59.999999999@Europe/Paris"),
-                                      ZonedDateTime.of(999999999, 12, 31, 23, 
59, 59, 999_999_999, ZoneId.of("Europe/Paris")));
-    }
-
-    @Test
-    void invokeParamStringDateOffset() {
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-12-31T23:59:59.999999999+02:00"),
-                                      ZonedDateTime.of(2017, 12, 31, 23, 59, 
59, 999_999_999, ZoneOffset.of("+02:00")));
-        
FunctionTestUtil.assertResult(dateTimeFunction.invoke("-999999999-12-31T23:59:59.999999999+02:00"),
-                                      ZonedDateTime.of(-999999999, 12, 31, 23, 
59, 59, 999_999_999, ZoneOffset.of(
-                                              "+02:00")));
-    }
-
-    @Test
-    void invokeParamStringDate() {
-        FunctionTestUtil.assertResult(dateTimeFunction.invoke("2017-09-07"), 
LocalDateTime.of(2017, 9, 7, 0, 0, 0));
-    }
-
-    @Test
-    void invokeParamTemporalNulls() {
-        FunctionTestUtil.assertResultError(dateTimeFunction.invoke((Temporal) 
null, null),
-                                           InvalidParametersEvent.class);
-        FunctionTestUtil.assertResultError(dateTimeFunction.invoke(null, 
LocalTime.of(10, 6, 20)),
-                                           InvalidParametersEvent.class);
-        
FunctionTestUtil.assertResultError(dateTimeFunction.invoke(LocalDate.of(2017, 
6, 12), null),
-                                           InvalidParametersEvent.class);
-    }
-
-    @Test
-    void invokeParamTemporalWrongTemporal() {
-        // reminder: 1st parameter accordingly to FEEL Spec Table 58 "date is 
a date or date time [...] creates a
-        // date time from the given date (ignoring any time component)" [that 
means ignoring any TZ from `date`
-        // parameter, too]
-        FunctionTestUtil.assertResultError(
-                dateTimeFunction.invoke(
-                        LocalDate.of(2017, 6, 12),
-                        LocalDateTime.of(2017, 6, 12, 0, 0)), 
InvalidParametersEvent.class);
-        FunctionTestUtil.assertResultError(
-                dateTimeFunction.invoke(
-                        LocalDateTime.of(2017, 6, 12, 0, 0),
-                        LocalDateTime.of(2017, 6, 12, 0, 0)), 
InvalidParametersEvent.class);
-    }
-
-    @Test
-    void invokeParamTemporalLocalTime() {
-        FunctionTestUtil.assertResult(
-                dateTimeFunction.invoke(
-                        LocalDate.of(2017, 6, 12),
-                        LocalTime.of(10, 6, 20)),
-                LocalDateTime.of(2017, 6, 12, 10, 6, 20));
-    }
-
-    @Test
-    void invokeParamTemporalOffsetTime() {
-        FunctionTestUtil.assertResult(
-                dateTimeFunction.invoke(
-                        LocalDate.of(2017, 6, 12),
-                        OffsetTime.of(10, 6, 20, 0, ZoneOffset.UTC)),
-                ZonedDateTime.of(2017, 6, 12, 10, 6, 20, 0, ZoneOffset.UTC));
-    }
-}
\ No newline at end of file


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

Reply via email to