From 2e13440482b81081ddff7f4bb9554f089d95d203 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 16 Aug 2017 11:09:25 +0200 Subject: [PATCH] Added a test that reuses classes and mappings from a real project --- pom.xml | 8 ++++++- .../jpa/converters/JPAConverterTest.java | 23 ++++++++++++++++++ src/test/resources/META-INF/date.xml | 24 +++++++++++++++++++ src/test/resources/META-INF/node.xml | 22 +++++++++++++++++ src/test/resources/META-INF/persistence.xml | 16 +++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/META-INF/date.xml create mode 100644 src/test/resources/META-INF/node.xml diff --git a/pom.xml b/pom.xml index 0c61b3d..0b86e21 100755 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 5.0.11.Final 1.0.0.Final 4.12 - 1.7.13 + 1.7.22 @@ -103,6 +103,12 @@ ${h2.version} test + + de.juplo.yourshouter.api + data-model + 1.5.1 + test + diff --git a/src/test/java/de/juplo/jpa/converters/JPAConverterTest.java b/src/test/java/de/juplo/jpa/converters/JPAConverterTest.java index 130aa7a..0ff1493 100644 --- a/src/test/java/de/juplo/jpa/converters/JPAConverterTest.java +++ b/src/test/java/de/juplo/jpa/converters/JPAConverterTest.java @@ -2,6 +2,8 @@ package de.juplo.jpa.converters; import de.juplo.jpa.converters.TimeConversions.FixedZoneIdStrategy; import de.juplo.jpa.converters.TimeConversions.FixedZoneOffsetStrategy; +import de.juplo.yourshouter.api.model.Date; +import java.time.LocalDate; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -28,6 +30,7 @@ public class JPAConverterTest ZonedDateTime zdt = ZonedDateTime.now(); OffsetDateTime odt = OffsetDateTime.now(); + LocalDate ld = LocalDate.now(); ZoneId defaultZone = ZoneId.systemDefault(); ZoneId otherZone = defaultZone.getId().equals("America/New_York") ? ZoneId.of("Europe/Berlin") : ZoneId.of("America/New_York"); @@ -104,6 +107,26 @@ public class JPAConverterTest } + @Test + public void testDataModel() + { + em = Persistence.createEntityManagerFactory("data-model").createEntityManager(); + Date date; + + TimeConversions.setZoneIdStrategy(new FixedZoneIdStrategy(defaultZone)); + date = new Date(); + date.setId("TEST"); + date.setDate(ld); + date.setStart(zdt); + date.setEnd(zdt); + persist(date); + date = retrieve(Date.class, date.getId()); + assertEquals(ld, date.getDate()); + assertEquals(zdt, date.getStart()); + assertEquals(zdt, date.getEnd()); + } + + private void persist(Object entity) { EntityTransaction tx = em.getTransaction(); diff --git a/src/test/resources/META-INF/date.xml b/src/test/resources/META-INF/date.xml new file mode 100644 index 0000000..e119473 --- /dev/null +++ b/src/test/resources/META-INF/date.xml @@ -0,0 +1,24 @@ + + + + de.juplo.yourshouter.api.model + + 17 + + + + + + + + + + + + + + diff --git a/src/test/resources/META-INF/node.xml b/src/test/resources/META-INF/node.xml new file mode 100644 index 0000000..04f8993 --- /dev/null +++ b/src/test/resources/META-INF/node.xml @@ -0,0 +1,22 @@ + + + + de.juplo.yourshouter.api.model + + + + + + + + + + + + + + diff --git a/src/test/resources/META-INF/persistence.xml b/src/test/resources/META-INF/persistence.xml index 603cd73..a7d213f 100644 --- a/src/test/resources/META-INF/persistence.xml +++ b/src/test/resources/META-INF/persistence.xml @@ -33,4 +33,20 @@ + + Example, taken from the data-model package + META-INF/node.xml + META-INF/date.xml + true + + + + + + + + + + + -- 2.20.1