public abstract class AbstractStorageStrategyIT
{
protected ChatHome chathome;
- protected ChatRoomFactory chatRoomFactory;
protected abstract StorageStrategy getStorageStrategy();
protected void start()
{
StorageStrategyITConfig config = getConfig();
- chathome = new SimpleChatHome(config.getChatHomeService());
- chatRoomFactory = config.getChatRoomFactory();
+ chathome = config.getChatHome();
}
protected void stop()
assertThat(chathome.getChatRooms().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();
Message m1 = chatroom.addMessage(1l,"peter", "Hallo, ich heiße Peter!").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.getChatRoom(chatRoomId)).emitsExactly(chatroom);
assertThat(chathome
- .getChatRoom(chatroom.getId())
+ .getChatRoom(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.getChatRoom(chatRoomId)).emitsExactly(chatroom);
assertThat(chathome
- .getChatRoom(chatroom.getId())
+ .getChatRoom(chatRoomId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(m1, m2, m3, m4);
}
assertThat(chathome.getChatRooms().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();
Message ma1 = chatroomA.addMessage(1l,"peter", "Hallo, ich heiße Peter!").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();
Message mb1 = chatroomB.addMessage(1l,"peter", "Hallo, ich heiße Uwe!").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.getChatRoom(chatRoomAId)).emitsExactly(chatroomA);
assertThat(chathome
- .getChatRoom(chatroomA.getId())
+ .getChatRoom(chatRoomAId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(ma1, ma2, ma3, ma4);
- assertThat(chathome.getChatRoom(chatroomB.getId())).emitsExactly(chatroomB);
+ assertThat(chathome.getChatRoom(chatRoomBId)).emitsExactly(chatroomB);
assertThat(chathome
- .getChatRoom(chatroomB.getId())
+ .getChatRoom(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.getChatRoom(chatRoomAId)).emitsExactly(chatroomA);
assertThat(chathome
- .getChatRoom(chatroomA.getId())
+ .getChatRoom(chatRoomAId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(ma1, ma2, ma3, ma4);
- assertThat(chathome.getChatRoom(chatroomB.getId())).emitsExactly(chatroomB);
+ assertThat(chathome.getChatRoom(chatRoomBId)).emitsExactly(chatroomB);
assertThat(chathome
- .getChatRoom(chatroomB.getId())
+ .getChatRoom(chatRoomBId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(mb1, mb2, mb3, mb4);
}
interface StorageStrategyITConfig
{
- ChatHomeService getChatHomeService();
- ChatRoomFactory getChatRoomFactory();
+ ChatHome getChatHome();
}
}