test: Added integration-test `InMemoryWithMongoDbStorageIT`
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / persistence / AbstractStorageStrategyIT.java
index 524e6f1..dc998ab 100644 (file)
@@ -16,34 +16,34 @@ import static pl.rzrz.assertj.reactor.Assertions.*;
 @Slf4j
 public abstract class AbstractStorageStrategyIT
 {
-  ChatHome chathome;
+  protected ChatHome chathome;
 
 
-  abstract StorageStrategy getStorageStrategy();
-  abstract Supplier<ChatHomeService> chatHomeServiceSupplier();
+  protected abstract StorageStrategy getStorageStrategy();
+  protected abstract Supplier<ChatHomeService> getChatHomeServiceSupplier();
 
-  void start()
+  protected void start()
   {
-    chathome = new ChatHome(chatHomeServiceSupplier().get());
+    chathome = new ChatHome(getChatHomeServiceSupplier().get());
   }
 
-  void stop()
+  protected void stop()
   {
-    getStorageStrategy().writeChatrooms(chathome.getChatRooms());
+    getStorageStrategy().write(chathome.getChatRooms());
   }
 
   @Test
-  void testStoreAndRecreate()
+  protected void testStoreAndRecreate()
   {
     start();
 
     assertThat(chathome.getChatRooms().toStream()).hasSize(0);
 
     ChatRoom chatroom = chathome.createChatroom("FOO").block();
-    Message m1 = chatroom.addMessage(1l,"Peter", "Hallo, ich heiße Peter!").block();
-    Message m2 = chatroom.addMessage(1l, "Ute", "Ich bin Ute...").block();
-    Message m3 = chatroom.addMessage(2l, "Peter", "Willst du mit mir gehen?").block();
-    Message m4 = chatroom.addMessage(1l, "Klaus", "Ja? Nein? Vielleicht??").block();
+    Message m1 = chatroom.addMessage(1l,"peter", "Hallo, ich heiße Peter!").block();
+    Message m2 = chatroom.addMessage(1l, "ute", "Ich bin Ute...").block();
+    Message m3 = chatroom.addMessage(2l, "peter", "Willst du mit mir gehen?").block();
+    Message m4 = chatroom.addMessage(1l, "klaus", "Ja? Nein? Vielleicht??").block();
 
     assertThat(chathome.getChatRooms().toStream()).containsExactlyElementsOf(List.of(chatroom));
     assertThat(chathome.getChatRoom(chatroom.getId())).emitsExactly(chatroom);