From edaffc16628d5fd0f1ed1054e384441327626922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Tue, 29 Apr 2025 10:11:20 +0200 Subject: [PATCH] Fix configuration in queryable unit test extension With this the queryable unit test extension (QueryableStoreExtension) uses the same jackson mapper configuration as in production. --- .../correct_mapper_for_queryable_tests.yaml | 2 ++ .../sonia/scm/store/QueryableStoreExtension.java | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 gradle/changelog/correct_mapper_for_queryable_tests.yaml diff --git a/gradle/changelog/correct_mapper_for_queryable_tests.yaml b/gradle/changelog/correct_mapper_for_queryable_tests.yaml new file mode 100644 index 0000000000..d83811131c --- /dev/null +++ b/gradle/changelog/correct_mapper_for_queryable_tests.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Mapper configuration in queryable unit test extension diff --git a/scm-queryable-test/src/main/java/sonia/scm/store/QueryableStoreExtension.java b/scm-queryable-test/src/main/java/sonia/scm/store/QueryableStoreExtension.java index f02d569296..2f6c57541f 100644 --- a/scm-queryable-test/src/main/java/sonia/scm/store/QueryableStoreExtension.java +++ b/scm-queryable-test/src/main/java/sonia/scm/store/QueryableStoreExtension.java @@ -16,9 +16,11 @@ package sonia.scm.store; -import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.util.StdDateFormat; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.AfterEachCallback; @@ -61,11 +63,15 @@ public class QueryableStoreExtension implements ParameterResolver, BeforeEachCal private SQLiteQueryableStoreFactory storeFactory; private static ObjectMapper getObjectMapper() { + // this should be the same as in ObjectMapperProvider return new ObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .registerModule(new Jdk8Module()) .registerModule(new JavaTimeModule()) - .configure(JsonParser.Feature.IGNORE_UNDEFINED, true) - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) + .configure(SerializationFeature.WRITE_DATES_WITH_ZONE_ID, true) + .setDateFormat(new StdDateFormat()); } @Override