From 8001147ef42751d270f49f8ebe22c18c5f32ad09 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Mon, 16 Sep 2024 09:47:41 +0100 Subject: [PATCH] [#662] XML dialects: Set the dialect in JPA module to the one based on java.time API. --- dmn-jpa-it/pom.xml | 2 +- .../com/gs/jpa/lazy_input_model/LazyPerson.java | 3 +-- .../JPAExampleCreditDecisionTest.java | 14 +++++++------- .../lazy_input_model/JPALazyInputModelTest.java | 13 ++++++------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dmn-jpa-it/pom.xml b/dmn-jpa-it/pom.xml index de2c9504b..b764fc101 100644 --- a/dmn-jpa-it/pom.xml +++ b/dmn-jpa-it/pom.xml @@ -89,7 +89,7 @@ jdmn-maven-plugin ${project.parent.version} - com.gs.dmn.dialect.MixedJavaTimeDMNDialectDefinition + com.gs.dmn.dialect.JavaTimeDMNDialectDefinition ${dmn.version} ${model.version} diff --git a/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java b/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java index 09f87bc23..16941e4fe 100644 --- a/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java +++ b/dmn-jpa-it/src/main/java/com/gs/jpa/lazy_input_model/LazyPerson.java @@ -18,7 +18,6 @@ import javax.persistence.EntityManager; import javax.persistence.TypedQuery; -import java.math.BigDecimal; public class LazyPerson implements Person { private static final Logger LOGGER = LoggerFactory.getLogger(LazyPerson.class); @@ -42,7 +41,7 @@ public String getName() { } @Override - public BigDecimal getAge() { + public Number getAge() { if (personJPA == null) { this.personJPA = findApplicant(id); } diff --git a/dmn-jpa-it/src/test/java/com/gs/jpa/example_credit_decision/JPAExampleCreditDecisionTest.java b/dmn-jpa-it/src/test/java/com/gs/jpa/example_credit_decision/JPAExampleCreditDecisionTest.java index a4a82efbd..bd3be2463 100644 --- a/dmn-jpa-it/src/test/java/com/gs/jpa/example_credit_decision/JPAExampleCreditDecisionTest.java +++ b/dmn-jpa-it/src/test/java/com/gs/jpa/example_credit_decision/JPAExampleCreditDecisionTest.java @@ -23,7 +23,7 @@ import javax.persistence.Persistence; import javax.persistence.TypedQuery; -public class JPAExampleCreditDecisionTest extends com.gs.dmn.runtime.MixedJavaTimeDMNBaseDecision { +public class JPAExampleCreditDecisionTest extends com.gs.dmn.runtime.JavaTimeDMNBaseDecision { protected static EntityManagerFactory emf; protected static EntityManager em; @@ -45,8 +45,8 @@ public void testCase001() { com.gs.dmn.runtime.ExecutionContext context = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data com.gs.dmn.generated.example_credit_decision.type.Applicant applicant = findApplicant("Amy"); - java.math.BigDecimal currentRiskAppetite = number("50"); - java.math.BigDecimal lendingThreshold = number("25"); + Number currentRiskAppetite = number("50"); + Number lendingThreshold = number("25"); // Check generateOutputData com.gs.dmn.generated.example_credit_decision.type.GenerateOutputData generateOutputDataOutput = new GenerateOutputData().apply(applicant, currentRiskAppetite, lendingThreshold, context); @@ -58,8 +58,8 @@ public void testCase002() { com.gs.dmn.runtime.ExecutionContext context = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data com.gs.dmn.generated.example_credit_decision.type.Applicant applicant = findApplicant("Bill"); - java.math.BigDecimal currentRiskAppetite = number("50"); - java.math.BigDecimal lendingThreshold = number("25"); + Number currentRiskAppetite = number("50"); + Number lendingThreshold = number("25"); // Check generateOutputData com.gs.dmn.generated.example_credit_decision.type.GenerateOutputData generateOutputDataOutput = new GenerateOutputData().apply(applicant, currentRiskAppetite, lendingThreshold, context); @@ -71,8 +71,8 @@ public void testCase003() { com.gs.dmn.runtime.ExecutionContext context = new com.gs.dmn.runtime.ExecutionContext(); // Initialize input data com.gs.dmn.generated.example_credit_decision.type.Applicant applicant = findApplicant("Charlie"); - java.math.BigDecimal currentRiskAppetite = number("50"); - java.math.BigDecimal lendingThreshold = number("25"); + Number currentRiskAppetite = number("50"); + Number lendingThreshold = number("25"); // Check generateOutputData com.gs.dmn.generated.example_credit_decision.type.GenerateOutputData generateOutputDataOutput = new GenerateOutputData().apply(applicant, currentRiskAppetite, lendingThreshold, context); diff --git a/dmn-jpa-it/src/test/java/com/gs/jpa/lazy_input_model/JPALazyInputModelTest.java b/dmn-jpa-it/src/test/java/com/gs/jpa/lazy_input_model/JPALazyInputModelTest.java index c7ab2aaff..f014ea66f 100644 --- a/dmn-jpa-it/src/test/java/com/gs/jpa/lazy_input_model/JPALazyInputModelTest.java +++ b/dmn-jpa-it/src/test/java/com/gs/jpa/lazy_input_model/JPALazyInputModelTest.java @@ -21,9 +21,8 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; -import java.math.BigDecimal; -public class JPALazyInputModelTest extends com.gs.dmn.runtime.MixedJavaTimeDMNBaseDecision { +public class JPALazyInputModelTest extends com.gs.dmn.runtime.JavaTimeDMNBaseDecision { protected static EntityManagerFactory emf; protected static EntityManager em; @@ -48,7 +47,7 @@ public void testCase001() { Person applicant = makeLazyPerson(1); // Check generateOutputData - BigDecimal score = new Decision().apply(applicant, creditRisk, context); + Number score = new Decision().apply(applicant, creditRisk, context); checkValues(number("1"), score); } @@ -60,7 +59,7 @@ public void testCase002() { Person applicant = makeLazyPerson(2); // Check generateOutputData - BigDecimal score = new Decision().apply(applicant, creditRisk, context); + Number score = new Decision().apply(applicant, creditRisk, context); checkValues(number("2"), score); } @@ -72,7 +71,7 @@ public void testCase003() { Person applicant = makeLazyPerson(3); // Check generateOutputData - BigDecimal score = new Decision().apply(applicant, creditRisk, context); + Number score = new Decision().apply(applicant, creditRisk, context); checkValues(number("3"), score); } @@ -84,7 +83,7 @@ public void testCase004() { Person applicant = makeLazyPerson(4); // Check generateOutputData - BigDecimal score = new Decision().apply(applicant, creditRisk, context); + Number score = new Decision().apply(applicant, creditRisk, context); checkValues(number("4"), score); } @@ -96,7 +95,7 @@ public void testCase005() { Person applicant = makeLazyPerson(1); // Check generateOutputData - BigDecimal score = new Decision().apply(applicant, creditRisk, context); + Number score = new Decision().apply(applicant, creditRisk, context); checkValues(number("5"), score); }