From 461ace0fef60fdc6c45c8f370d24ab7af9fa35ad Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 10 Jan 2023 19:32:55 +0100 Subject: [PATCH] WIP --- .../InMemoryWithMongoDbStorageStrategyIT.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java index 06b6c2da..37d14942 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java @@ -3,6 +3,7 @@ package de.juplo.kafka.chat.backend.persistence; import de.juplo.kafka.chat.backend.domain.ChatHomeService; import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatHomeService; import de.juplo.kafka.chat.backend.persistence.InMemoryWithMongoDbStorageStrategyIT.DataSourceInitializer; +import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService; import de.juplo.kafka.chat.backend.persistence.storage.mongodb.ChatHomeRepository; import de.juplo.kafka.chat.backend.persistence.storage.mongodb.MongoDbStorageStrategy; import lombok.extern.slf4j.Slf4j; @@ -10,8 +11,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo; +import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Bean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.TestPropertySourceUtils; @@ -49,6 +52,31 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg return () -> new InMemoryChatHomeService(getStorageStrategy().read(), clock, 8); } + + @TestConfiguration + static class InMemoryWithMongoDbStorageStrategyITConfig + { + @Bean + MongoDbStorageStrategy storageStrategy( + ChatHomeRepository repository, + Clock clock + ) + { + return new MongoDbStorageStrategy( + repository, + clock, + 8, + messageFlux -> new InMemoryChatRoomService(messageFlux)); + } + + @Bean + Clock clock() + { + return Clock.systemDefaultZone(); + } + } + + @Container private static final GenericContainer mongodb = new GenericContainer("mongo:6") -- 2.20.1