From 6126d097334b15c98c5668d4d371292276a8edaa Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 4 Sep 2023 22:52:39 +0200 Subject: [PATCH] refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code --- .../persistence/inmemory/InMemoryServicesConfiguration.java | 3 --- .../chat/backend/persistence/inmemory/SimpleChatHome.java | 5 +---- .../chat/backend/persistence/AbstractInMemoryStorageIT.java | 3 ++- .../chat/backend/persistence/AbstractStorageStrategyIT.java | 2 +- .../backend/persistence/inmemory/ShardedChatHomeTest.java | 2 +- .../backend/persistence/inmemory/SimpleChatHomeTest.java | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java index 47c223e8..16115825 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java @@ -29,12 +29,10 @@ public class InMemoryServicesConfiguration ChatHome noneShardingChatHome( ChatBackendProperties properties, StorageStrategy storageStrategy, - ChatRoomServiceFactory chatRoomServiceFactory, Clock clock) { return new SimpleChatHome( storageStrategy, - chatRoomServiceFactory, clock, properties.getChatroomBufferSize()); } @@ -57,7 +55,6 @@ public class InMemoryServicesConfiguration .forEach(shard -> chatHomes[shard] = new SimpleChatHome( shard, storageStrategy, - chatRoomServiceFactory, clock, properties.getChatroomBufferSize())); ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards); diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java index 51147c51..c6f33778 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java @@ -24,14 +24,12 @@ public class SimpleChatHome implements ChatHome public SimpleChatHome( StorageStrategy storageStrategy, - ChatRoomServiceFactory chatRoomServiceFactory, Clock clock, int bufferSize) { this( null, storageStrategy, - chatRoomServiceFactory, clock, bufferSize); } @@ -39,7 +37,6 @@ public class SimpleChatHome implements ChatHome public SimpleChatHome( Integer shard, StorageStrategy storageStrategy, - ChatRoomServiceFactory chatRoomServiceFactory, Clock clock, int bufferSize) { @@ -76,7 +73,7 @@ public class SimpleChatHome implements ChatHome info.getId(), new ChatRoomData( clock, - chatRoomServiceFactory.create(messageFlux), + new InMemoryChatRoomService(messageFlux), bufferSize)); }); this.clock = clock; diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java index b5d0cd42..d984db3a 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java @@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.persistence; import de.juplo.kafka.chat.backend.domain.ChatHome; import de.juplo.kafka.chat.backend.persistence.inmemory.SimpleChatHome; +import de.juplo.kafka.chat.backend.persistence.storage.files.ChatRoomServiceFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -22,7 +23,7 @@ public abstract class AbstractInMemoryStorageIT extends AbstractStorageStrategyI int bufferSize = 8; SimpleChatHome simpleChatHome = new SimpleChatHome( - getStorageStrategy().readChatRoomData(), + getStorageStrategy(), clock, bufferSize); 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 f9cd11f1..5132c656 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 @@ -27,7 +27,7 @@ public abstract class AbstractStorageStrategyIT protected void stop() { - getStorageStrategy().writeChatRoomData(chathome.getChatRoomData()); + getStorageStrategy().write(chathome); } @Test diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java index 22c37d18..652ade84 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java @@ -27,7 +27,7 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTest .of(ownedShards()) .forEach(shard -> chatHomes[shard] = new SimpleChatHome( shard, - storageStrategy.readChatRoomData(), + storageStrategy, clock, bufferSize())); diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java index 1140f69b..7103bb67 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java @@ -22,7 +22,7 @@ public class SimpleChatHomeTest extends ChatHomeTest Clock clock) { return new SimpleChatHome( - storageStrategy.readChatRoomData(), + storageStrategy, clock, bufferSize()); } -- 2.20.1