From: Kai Moritz Date: Mon, 19 Feb 2024 13:50:34 +0000 (+0100) Subject: test: Added missing JSR-310 module to not Spring-Boot-based tests X-Git-Tag: rebase--2024-02-20--10-29~5 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c7cc5cb1c81cafdebe0ff3ffe75446bd90a48930;p=demos%2Fkafka%2Fchat test: Added missing JSR-310 module to not Spring-Boot-based tests --- diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/ShardedChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/ShardedChatHomeServiceTest.java index b830f300..8ed18448 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/ShardedChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/ShardedChatHomeServiceTest.java @@ -1,6 +1,7 @@ package de.juplo.kafka.chat.backend.implementation.inmemory; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest; import de.juplo.kafka.chat.backend.implementation.ShardingStrategy; import de.juplo.kafka.chat.backend.implementation.StorageStrategy; @@ -47,12 +48,22 @@ public class ShardedChatHomeServiceTest extends ChatHomeServiceWithShardsTest } @Bean - public FilesStorageStrategy storageStrategy(Clock clock) + FilesStorageStrategy storageStrategy( + Clock clock, + ObjectMapper objectMapper) { return new FilesStorageStrategy( Paths.get("target", "test-classes", "data", "files"), new KafkaLikeShardingStrategy(NUM_SHARDS), - new ObjectMapper()); + objectMapper); + } + + @Bean + ObjectMapper objectMapper() + { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + return objectMapper; } @Bean diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeServiceTest.java index d90696dd..b967df82 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeServiceTest.java @@ -1,6 +1,7 @@ package de.juplo.kafka.chat.backend.implementation.inmemory; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.juplo.kafka.chat.backend.domain.ChatHomeServiceTest; import de.juplo.kafka.chat.backend.implementation.StorageStrategy; import de.juplo.kafka.chat.backend.storage.files.FilesStorageStrategy; @@ -28,12 +29,22 @@ public class SimpleChatHomeServiceTest extends ChatHomeServiceTest } @Bean - public FilesStorageStrategy storageStrategy(Clock clock) + FilesStorageStrategy storageStrategy( + Clock clock, + ObjectMapper objectMapper) { return new FilesStorageStrategy( Paths.get("target", "test-classes", "data", "files"), chatRoomId -> 0, - new ObjectMapper()); + objectMapper); + } + + @Bean + ObjectMapper objectMapper() + { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + return objectMapper; } @Bean