X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Fkafka%2Fchat%2Fbackend%2Fpersistence%2FAbstractStorageStrategyIT.java;h=e619649aaf25311ed8d6344c1fd4760dfcb50f7b;hb=df207aa9a8cd349fd43785270d250a7f55593801;hp=58acb192eb9d7dd6521e8e6ae6396ec7d80f4e91;hpb=0ff0e013a3d1f112f8e8c7280a4948ce0662eb10;p=demos%2Fkafka%2Fchat diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java index 58acb192..e619649a 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java @@ -14,7 +14,6 @@ import static pl.rzrz.assertj.reactor.Assertions.*; public abstract class AbstractStorageStrategyIT { protected ChatHome chathome; - protected ChatRoomFactory chatRoomFactory; protected abstract StorageStrategy getStorageStrategy(); @@ -24,12 +23,11 @@ public abstract class AbstractStorageStrategyIT { StorageStrategyITConfig config = getConfig(); chathome = config.getChatHome(); - chatRoomFactory = config.getChatRoomFactory(); } protected void stop() { - getStorageStrategy().write(chathome.getChatRooms()); + getStorageStrategy().write(chathome); } @Test @@ -37,30 +35,30 @@ public abstract class AbstractStorageStrategyIT { start(); - assertThat(chathome.getChatRooms().toStream()).hasSize(0); + assertThat(chathome.getChatRoomInfo().toStream()).hasSize(0); UUID chatRoomId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7"); - ChatRoomInfo info = chatRoomFactory.createChatRoom(chatRoomId, "FOO").block(); + ChatRoomInfo info = chathome.createChatRoom(chatRoomId, "FOO").block(); log.debug("Created chat-room {}", info); - ChatRoom chatroom = chathome.getChatRoom(chatRoomId).block(); + ChatRoomData chatroom = chathome.getChatRoomData(chatRoomId).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); + assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyElementsOf(List.of(info)); + assertThat(chathome.getChatRoomInfo(chatRoomId)).emitsExactly(info); assertThat(chathome - .getChatRoom(chatroom.getId()) + .getChatRoomData(chatRoomId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(m1, m2, m3, m4); stop(); start(); - assertThat(chathome.getChatRooms().toStream()).containsExactlyElementsOf(List.of(chatroom)); - assertThat(chathome.getChatRoom(chatroom.getId())).emitsExactly(chatroom); + assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyElementsOf(List.of(info)); + assertThat(chathome.getChatRoomInfo(chatRoomId)).emitsExactly(info); assertThat(chathome - .getChatRoom(chatroom.getId()) + .getChatRoomData(chatRoomId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(m1, m2, m3, m4); } @@ -69,47 +67,47 @@ public abstract class AbstractStorageStrategyIT { start(); - assertThat(chathome.getChatRooms().toStream()).hasSize(0); + assertThat(chathome.getChatRoomInfo().toStream()).hasSize(0); UUID chatRoomAId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7"); - ChatRoomInfo infoA = chatRoomFactory.createChatRoom(chatRoomAId, "FOO").block(); + ChatRoomInfo infoA = chathome.createChatRoom(chatRoomAId, "FOO").block(); log.debug("Created chat-room {}", infoA); - ChatRoom chatroomA = chathome.getChatRoom(chatRoomAId).block(); + ChatRoomData chatroomA = chathome.getChatRoomData(chatRoomAId).block(); Message ma1 = chatroomA.addMessage(1l,"peter", "Hallo, ich heiße Peter!").block(); Message ma2 = chatroomA.addMessage(1l, "ute", "Ich bin Ute...").block(); Message ma3 = chatroomA.addMessage(2l, "peter", "Willst du mit mir gehen?").block(); Message ma4 = chatroomA.addMessage(1l, "klaus", "Ja? Nein? Vielleicht??").block(); UUID chatRoomBId = UUID.fromString("8763dfdc-4dda-4a74-bea4-4b389177abea"); - ChatRoomInfo infoB = chatRoomFactory.createChatRoom(chatRoomBId, "BAR").block(); + ChatRoomInfo infoB = chathome.createChatRoom(chatRoomBId, "BAR").block(); log.debug("Created chat-room {}", infoB); - ChatRoom chatroomB = chathome.getChatRoom(chatRoomBId).block(); + ChatRoomData chatroomB = chathome.getChatRoomData(chatRoomBId).block(); Message mb1 = chatroomB.addMessage(1l,"peter", "Hallo, ich heiße Uwe!").block(); Message mb2 = chatroomB.addMessage(1l, "ute", "Ich bin Ute...").block(); Message mb3 = chatroomB.addMessage(1l, "klaus", "Willst du mit mir gehen?").block(); Message mb4 = chatroomB.addMessage(2l, "peter", "Hä? Was jetzt?!? Isch glohb isch höb ühn däjah vüh...").block(); - assertThat(chathome.getChatRooms().toStream()).containsExactlyInAnyOrderElementsOf(List.of(chatroomA, chatroomB)); - assertThat(chathome.getChatRoom(chatroomA.getId())).emitsExactly(chatroomA); + assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyInAnyOrderElementsOf(List.of(infoA, infoB)); + assertThat(chathome.getChatRoomInfo(chatRoomAId)).emitsExactly(infoA); assertThat(chathome - .getChatRoom(chatroomA.getId()) + .getChatRoomData(chatRoomAId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(ma1, ma2, ma3, ma4); - assertThat(chathome.getChatRoom(chatroomB.getId())).emitsExactly(chatroomB); + assertThat(chathome.getChatRoomData(chatRoomBId)).emitsExactly(chatroomB); assertThat(chathome - .getChatRoom(chatroomB.getId()) + .getChatRoomData(chatRoomBId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(mb1, mb2, mb3, mb4); stop(); start(); - assertThat(chathome.getChatRooms().toStream()).containsExactlyInAnyOrderElementsOf(List.of(chatroomA, chatroomB)); - assertThat(chathome.getChatRoom(chatroomA.getId())).emitsExactly(chatroomA); + assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyInAnyOrderElementsOf(List.of(infoA, infoB)); + assertThat(chathome.getChatRoomInfo(chatRoomAId)).emitsExactly(infoA); assertThat(chathome - .getChatRoom(chatroomA.getId()) + .getChatRoomData(chatRoomAId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(ma1, ma2, ma3, ma4); - assertThat(chathome.getChatRoom(chatroomB.getId())).emitsExactly(chatroomB); + assertThat(chathome.getChatRoomInfo(chatRoomBId)).emitsExactly(infoB); assertThat(chathome - .getChatRoom(chatroomB.getId()) + .getChatRoomData(chatRoomBId) .flatMapMany(cr -> cr.getMessages())).emitsExactly(mb1, mb2, mb3, mb4); } @@ -117,6 +115,5 @@ public abstract class AbstractStorageStrategyIT interface StorageStrategyITConfig { ChatHome getChatHome(); - ChatRoomFactory getChatRoomFactory(); } }