WIP
authorKai Moritz <kai@juplo.de>
Tue, 10 Jan 2023 18:32:55 +0000 (19:32 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 10 Jan 2023 18:32:55 +0000 (19:32 +0100)
src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java

index 06b6c2d..37d1494 100644 (file)
@@ -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")