From bedb7b1d031aa19cbbdc29f34b3a128d1b2de739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 31 Oct 2023 15:44:45 +0100 Subject: [PATCH] Fix assertions in Hibernate ORM 5.6 compatibility tests Hibernate ORM 5.6 does not, in fact, preserve information for OffsetTime columns. It just slaps the current JVM timezone on a stored LocalTime. --- .../main/java/io/quarkus/it/hibernate/compatibility/Main.java | 2 +- .../quarkus/it/hibernate/compatibility/CompatibilityTest.java | 3 +-- .../quarkus/it/hibernate/compatibility/CompatibilityTest.java | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/integration-tests/hibernate-orm-compatibility-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/Main.java b/integration-tests/hibernate-orm-compatibility-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/Main.java index ab7f62e39ff7b..10b01e4b1397e 100644 --- a/integration-tests/hibernate-orm-compatibility-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/Main.java +++ b/integration-tests/hibernate-orm-compatibility-5.6/database-generator/src/main/java/io/quarkus/it/hibernate/compatibility/Main.java @@ -72,7 +72,7 @@ public int run(String... args) { checkEqual(createdEntity.duration, loadedEntity.duration); checkEqual(createdEntity.uuid, loadedEntity.uuid); checkEqual(createdEntity.instant, loadedEntity.instant); - checkEqual(createdEntity.offsetTime.withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())), + checkEqual(createdEntity.offsetTime.toLocalTime().atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now())), loadedEntity.offsetTime); checkEqual(createdEntity.offsetDateTime.atZoneSameInstant(ZoneId.systemDefault()).toOffsetDateTime(), loadedEntity.offsetDateTime); diff --git a/integration-tests/hibernate-orm-compatibility-5.6/mariadb/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java b/integration-tests/hibernate-orm-compatibility-5.6/mariadb/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java index ebdf74a1815d0..d326e27317dde 100644 --- a/integration-tests/hibernate-orm-compatibility-5.6/mariadb/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java +++ b/integration-tests/hibernate-orm-compatibility-5.6/mariadb/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java @@ -120,9 +120,8 @@ public void instant() { public void offsetTime() { assertThat(findOld().offsetTime) .isEqualTo(LocalTime.of(12, 58, 30, 0) - .atOffset(ZoneOffset.ofHours(2)) // Hibernate ORM 5 used to normalize these values to the JVM TZ - .withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now()))); + .atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now()))); } // https://github.com/hibernate/hibernate-orm/blob/6.2/migration-guide.adoc#timezone-and-offset-storage diff --git a/integration-tests/hibernate-orm-compatibility-5.6/postgresql/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java b/integration-tests/hibernate-orm-compatibility-5.6/postgresql/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java index e6ed294c77e5e..4f5934a6293d3 100644 --- a/integration-tests/hibernate-orm-compatibility-5.6/postgresql/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java +++ b/integration-tests/hibernate-orm-compatibility-5.6/postgresql/src/test/java/io/quarkus/it/hibernate/compatibility/CompatibilityTest.java @@ -120,9 +120,8 @@ public void instant() { public void offsetTime() { assertThat(findOld().offsetTime) .isEqualTo(LocalTime.of(12, 58, 30, 0) - .atOffset(ZoneOffset.ofHours(2)) // Hibernate ORM 5 used to normalize these values to the JVM TZ - .withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now()))); + .atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now()))); } // https://github.com/hibernate/hibernate-orm/blob/6.2/migration-guide.adoc#timezone-and-offset-storage