From: Kai Moritz Date: Tue, 10 Jan 2023 18:32:55 +0000 (+0100) Subject: WIP X-Git-Tag: TEST~5 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=461ace0fef60fdc6c45c8f370d24ab7af9fa35ad;p=demos%2Fkafka%2Fchat WIP --- 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")