From f5001046279efbc1996106938b16eca904a71218 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Wed, 19 Jun 2024 02:46:41 +0100 Subject: [PATCH] [#678] Fix native type mapping in java time dialects --- .../dialect/JavaTimeDMNDialectDefinition.java | 4 ++-- ...vaTimeKotlinStandardDMNDialectDefinition.java | 4 ++-- dmn-tck-it/dmn-tck-it-translator/pom.xml | 2 +- .../DateTimeProtoHandwrittenTest.java | 11 +++++++---- .../translator/0068-feel-equality-test-01.xml | 16 ++++++++-------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeDMNDialectDefinition.java b/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeDMNDialectDefinition.java index ce13a21bd..d8c8eb032 100644 --- a/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeDMNDialectDefinition.java +++ b/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeDMNDialectDefinition.java @@ -82,12 +82,12 @@ public String getNativeDateType() { @Override public String getNativeTimeType() { - return Temporal.class.getName(); + return TemporalAccessor.class.getName(); } @Override public String getNativeDateAndTimeType() { - return Temporal.class.getName(); + return TemporalAccessor.class.getName(); } @Override diff --git a/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeKotlinStandardDMNDialectDefinition.java b/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeKotlinStandardDMNDialectDefinition.java index f59ef9a15..39a90fa0e 100644 --- a/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeKotlinStandardDMNDialectDefinition.java +++ b/dmn-core/src/main/java/com/gs/dmn/dialect/JavaTimeKotlinStandardDMNDialectDefinition.java @@ -84,12 +84,12 @@ public String getNativeDateType() { @Override public String getNativeTimeType() { - return OffsetTime.class.getName(); + return TemporalAccessor.class.getName(); } @Override public String getNativeDateAndTimeType() { - return ZonedDateTime.class.getName(); + return TemporalAccessor.class.getName(); } @Override diff --git a/dmn-tck-it/dmn-tck-it-translator/pom.xml b/dmn-tck-it/dmn-tck-it-translator/pom.xml index 89499d725..b8d36e253 100644 --- a/dmn-tck-it/dmn-tck-it-translator/pom.xml +++ b/dmn-tck-it/dmn-tck-it-translator/pom.xml @@ -56,7 +56,7 @@ jdmn-maven-plugin ${project.parent.version} - com.gs.dmn.dialect.StandardDMNDialectDefinition + com.gs.dmn.dialect.JavaTimeDMNDialectDefinition com.gs.dmn.transformation.ToQuotedNameTransformer diff --git a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/proto/date_time_proto/DateTimeProtoHandwrittenTest.java b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/proto/date_time_proto/DateTimeProtoHandwrittenTest.java index e1ce25fe3..fd3d09564 100644 --- a/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/proto/date_time_proto/DateTimeProtoHandwrittenTest.java +++ b/dmn-tck-it/dmn-tck-it-translator/src/test/java/com/gs/dmn/generated/proto/date_time_proto/DateTimeProtoHandwrittenTest.java @@ -2,7 +2,10 @@ import org.junit.jupiter.api.Test; -public class DateTimeProtoHandwrittenTest extends com.gs.dmn.runtime.DefaultDMNBaseDecision { +import java.time.LocalDate; +import java.time.temporal.TemporalAccessor; + +public class DateTimeProtoHandwrittenTest extends com.gs.dmn.runtime.JavaTimeDMNBaseDecision { private final Date dateDecision = new Date(); private final Time timeDecision = new Time(); private final DateTime dateTimeDecision = new DateTime(); @@ -11,7 +14,7 @@ public class DateTimeProtoHandwrittenTest extends com.gs.dmn.runtime.DefaultDMNB public void testCase1() { com.gs.dmn.runtime.ExecutionContext context_ = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data - javax.xml.datatype.XMLGregorianCalendar inputDate = date("2020-09-10"); + LocalDate inputDate = date("2020-09-10"); // Check Date checkValues(date("2020-09-10"), dateDecision.apply(inputDate, context_)); @@ -28,7 +31,7 @@ public void testCase1() { public void testCase2() { com.gs.dmn.runtime.ExecutionContext context_ = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data - javax.xml.datatype.XMLGregorianCalendar inputTime = time("12:10:10"); + TemporalAccessor inputTime = time("12:10:10"); // Check Time checkValues(time("12:10:10"), timeDecision.apply(inputTime, context_)); @@ -45,7 +48,7 @@ public void testCase2() { public void testCase3() { com.gs.dmn.runtime.ExecutionContext context_ = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data - javax.xml.datatype.XMLGregorianCalendar inputDateTime = dateAndTime("2020-09-19T12:10:10"); + TemporalAccessor inputDateTime = dateAndTime("2020-09-19T12:10:10"); // Check DateTime checkValues(dateAndTime("2020-09-19T12:10:10"), dateTimeDecision.apply(inputDateTime, context_)); diff --git a/dmn-test-cases/standard/tck/1.3/cl3/0068-feel-equality/translator/0068-feel-equality-test-01.xml b/dmn-test-cases/standard/tck/1.3/cl3/0068-feel-equality/translator/0068-feel-equality-test-01.xml index 457a29a8e..c23d1fd35 100644 --- a/dmn-test-cases/standard/tck/1.3/cl3/0068-feel-equality/translator/0068-feel-equality-test-01.xml +++ b/dmn-test-cases/standard/tck/1.3/cl3/0068-feel-equality/translator/0068-feel-equality-test-01.xml @@ -567,14 +567,14 @@ - - same times = one with offset, the other with zone are equal if offsets are equal - - - true - - - + + + + + + + +