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.api.ShardingStrategy;
import de.juplo.kafka.chat.backend.domain.ChatHomeService;
-import de.juplo.kafka.chat.backend.persistence.filestorage.FileStorageStrategy;
+import de.juplo.kafka.chat.backend.domain.ChatRoomFactory;
+import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomFactory;
+import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy;
import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatHomeService;
import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class InMemoryWithFileStorageStrategyIT extends AbstractStorageStrategyIT
+public class InMemoryWithFilesStorageStrategyIT extends AbstractStorageStrategyIT
{
final static Path path = Paths.get("target","local-json-files");
final Clock clock;
final ObjectMapper mapper;
- final FileStorageStrategy storageStrategy;
+ final FilesStorageStrategy storageStrategy;
- public InMemoryWithFileStorageStrategyIT()
+ public InMemoryWithFilesStorageStrategyIT()
{
clock = Clock.systemDefaultZone();
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
- storageStrategy = new FileStorageStrategy(
+ storageStrategy = new FilesStorageStrategy(
path,
clock,
8,
}
@Override
- protected Supplier<ChatHomeService> chatHomeServiceSupplier()
+ protected Supplier<ChatHomeService> getChatHomeServiceSupplier()
{
- return () -> new InMemoryChatHomeService(getStorageStrategy().readChatrooms(), clock, 8);
+ return () -> new InMemoryChatHomeService(1, getStorageStrategy().read());
+ }
+
+ @Override
+ protected ChatRoomFactory getChatRoomFactory()
+ {
+ ShardingStrategy strategy = chatRoomId -> 0;
+ return new InMemoryChatRoomFactory(strategy, clock, 8);
}
@BeforeEach