import java.util.List;
import java.util.UUID;
-import java.util.function.Supplier;
import static pl.rzrz.assertj.reactor.Assertions.*;
protected abstract StorageStrategy getStorageStrategy();
- protected abstract Supplier<ChatHomeService> getChatHomeServiceSupplier();
- protected abstract ChatRoomFactory getChatRoomFactory();
+ protected abstract StorageStrategyITConfig getConfig();
protected void start()
{
- chathome = new SimpleChatHome(getChatHomeServiceSupplier().get());
- chatRoomFactory = getChatRoomFactory();
+ StorageStrategyITConfig config = getConfig();
+ chathome = new SimpleChatHome(config.getChatHomeService());
+ chatRoomFactory = config.getChatRoomFactory();
}
protected void stop()
.getChatRoom(chatroomB.getId())
.flatMapMany(cr -> cr.getMessages())).emitsExactly(mb1, mb2, mb3, mb4);
}
+
+
+ interface StorageStrategyITConfig
+ {
+ ChatHomeService getChatHomeService();
+ ChatRoomFactory getChatRoomFactory();
+ }
}
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import de.juplo.kafka.chat.backend.domain.ShardingStrategy;
import de.juplo.kafka.chat.backend.domain.ChatHomeService;
import de.juplo.kafka.chat.backend.domain.ChatRoomFactory;
import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomFactory;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Clock;
-import java.util.function.Supplier;
@Slf4j
}
@Override
- protected Supplier<ChatHomeService> getChatHomeServiceSupplier()
+ protected StorageStrategyITConfig getConfig()
{
- return () -> new InMemoryChatHomeService(
- 1,
- new int[] { 0 },
- getStorageStrategy().read());
- }
+ return new StorageStrategyITConfig()
+ {
+ InMemoryChatHomeService chatHomeService = new InMemoryChatHomeService(
+ 1,
+ new int[] { 0 },
+ getStorageStrategy().read());
- @Override
- protected ChatRoomFactory getChatRoomFactory()
- {
- ShardingStrategy strategy = chatRoomId -> 0;
- return new InMemoryChatRoomFactory(strategy, clock, 8);
+ InMemoryChatRoomFactory chatRoomFactory = new InMemoryChatRoomFactory(
+ chatRoomId -> 0,
+ clock,
+ 8);
+
+ @Override
+ public ChatHomeService getChatHomeService()
+ {
+ return chatHomeService;
+ }
+
+ @Override
+ public ChatRoomFactory getChatRoomFactory()
+ {
+ return chatRoomFactory;
+ }
+ };
}
@BeforeEach
package de.juplo.kafka.chat.backend.persistence;
-import de.juplo.kafka.chat.backend.domain.ShardingStrategy;
import de.juplo.kafka.chat.backend.domain.ChatHomeService;
import de.juplo.kafka.chat.backend.domain.ChatRoomFactory;
import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatHomeService;
import org.testcontainers.junit.jupiter.Testcontainers;
import java.time.Clock;
-import java.util.function.Supplier;
@Testcontainers
}
@Override
- protected Supplier<ChatHomeService> getChatHomeServiceSupplier()
+ protected StorageStrategyITConfig getConfig()
{
- return () -> new InMemoryChatHomeService(
- 1,
- new int[] { 0 },
- getStorageStrategy().read());
- }
+ return new StorageStrategyITConfig()
+ {
+ InMemoryChatHomeService chatHomeService = new InMemoryChatHomeService(
+ 1,
+ new int[] { 0 },
+ getStorageStrategy().read());
- @Override
- protected ChatRoomFactory getChatRoomFactory()
- {
- ShardingStrategy strategy = chatRoomId -> 0;
- return new InMemoryChatRoomFactory(strategy, clock, 8);
+ InMemoryChatRoomFactory chatRoomFactory = new InMemoryChatRoomFactory(
+ chatRoomId -> 0,
+ clock,
+ 8);
+
+ @Override
+ public ChatHomeService getChatHomeService()
+ {
+ return chatHomeService;
+ }
+
+ @Override
+ public ChatRoomFactory getChatRoomFactory()
+ {
+ return chatRoomFactory;
+ }
+ };
}
@TestConfiguration