@Slf4j
public abstract class AbstractStorageStrategyIT
{
+ @Autowired
ChatHomeService chathome;
-
@Autowired
StorageStrategy storageStrategy;
- abstract ChatHomeService getChatHome();
- protected void start()
- {
- chathome = getChatHome();
- }
+ abstract void restore();
- protected void stop()
+ void store()
{
storageStrategy
.write(chathome)
- .subscribe();
+ .block();
}
@Test
- protected void testStoreAndRecreate()
+ void testStoreAndRecreate()
{
- start();
+ restore();
assertThat(chathome.getChatRoomInfo().toStream()).hasSize(0);
.getChatRoomData(chatRoomId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(m1, m2, m3, m4);
- stop();
- start();
+ store();
+ restore();
assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyElementsOf(List.of(info));
assertThat(chathome.getChatRoomInfo(chatRoomId)).emitsExactly(info);
}
@Test
- protected void testStoreAndRecreateParallelChatRooms()
+ void testStoreAndRecreateParallelChatRooms()
{
- start();
+ restore();
assertThat(chathome.getChatRoomInfo().toStream()).hasSize(0);
.getChatRoomData(chatRoomBId)
.flatMapMany(cr -> cr.getMessages())).emitsExactly(mb1, mb2, mb3, mb4);
- stop();
- start();
+ store();
+ restore();
assertThat(chathome.getChatRoomInfo().toStream()).containsExactlyInAnyOrderElementsOf(List.of(infoA, infoB));
assertThat(chathome.getChatRoomInfo(chatRoomAId)).emitsExactly(infoA);