refactor: `ChatHome` is a service - Aligned code
authorKai Moritz <kai@juplo.de>
Wed, 6 Sep 2023 21:41:37 +0000 (23:41 +0200)
committerKai Moritz <kai@juplo.de>
Tue, 20 Feb 2024 09:35:31 +0000 (10:35 +0100)
17 files changed:
src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java
src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/persistence/StorageStrategy.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaServicesConfiguration.java
src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java
src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java
src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceWithShardsTest.java
src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeServiceTest.java
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeServiceTest.java
src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHomeServiceTest.java

index 15f8ae1..e2c3562 100644 (file)
@@ -1,6 +1,6 @@
 package de.juplo.kafka.chat.backend;
 
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
 import jakarta.annotation.PreDestroy;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +16,7 @@ public class ChatBackendApplication implements WebFluxConfigurer
        @Autowired
        ChatBackendProperties properties;
        @Autowired
-       ChatHome chatHome;
+       ChatHomeService chatHomeService;
        @Autowired
        StorageStrategy storageStrategy;
 
@@ -32,7 +32,7 @@ public class ChatBackendApplication implements WebFluxConfigurer
        @PreDestroy
        public void onExit()
        {
-               storageStrategy.write(chatHome);
+               storageStrategy.write(chatHomeService);
        }
 
        public static void main(String[] args)
index e2fe714..7f29b16 100644 (file)
@@ -1,6 +1,6 @@
 package de.juplo.kafka.chat.backend.api;
 
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.domain.ChatRoomData;
 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
 import lombok.RequiredArgsConstructor;
@@ -16,7 +16,7 @@ import java.util.UUID;
 @RequiredArgsConstructor
 public class ChatBackendController
 {
-  private final ChatHome chatHome;
+  private final ChatHomeService chatHomeService;
   private final StorageStrategy storageStrategy;
 
 
@@ -24,7 +24,7 @@ public class ChatBackendController
   public Mono<ChatRoomInfoTo> create(@RequestBody String name)
   {
     UUID chatRoomId = UUID.randomUUID();
-    return chatHome
+    return chatHomeService
         .createChatRoom(chatRoomId, name)
         .map(ChatRoomInfoTo::from);
   }
@@ -32,7 +32,7 @@ public class ChatBackendController
   @GetMapping("list")
   public Flux<ChatRoomInfoTo> list()
   {
-    return chatHome
+    return chatHomeService
         .getChatRoomInfo()
         .map(chatroomInfo -> ChatRoomInfoTo.from(chatroomInfo));
   }
@@ -40,7 +40,7 @@ public class ChatBackendController
   @GetMapping("{chatRoomId}/list")
   public Flux<MessageTo> list(@PathVariable UUID chatRoomId)
   {
-    return chatHome
+    return chatHomeService
         .getChatRoomData(chatRoomId)
         .flatMapMany(chatRoomData -> chatRoomData
             .getMessages()
@@ -50,7 +50,7 @@ public class ChatBackendController
   @GetMapping("{chatRoomId}")
   public Mono<ChatRoomInfoTo> get(@PathVariable UUID chatRoomId)
   {
-    return chatHome
+    return chatHomeService
         .getChatRoomInfo(chatRoomId)
         .map(chatRoomInfo -> ChatRoomInfoTo.from(chatRoomInfo));
   }
@@ -63,7 +63,7 @@ public class ChatBackendController
       @RequestBody String text)
   {
     return
-        chatHome
+        chatHomeService
             .getChatRoomData(chatRoomId)
             .flatMap(chatRoomData -> put(chatRoomData, username, messageId, text));
   }
@@ -90,7 +90,7 @@ public class ChatBackendController
       @PathVariable Long messageId)
   {
     return
-        chatHome
+        chatHomeService
             .getChatRoomData(chatRoomId)
             .flatMap(chatRoomData -> get(chatRoomData, username, messageId));
   }
@@ -109,7 +109,7 @@ public class ChatBackendController
   @GetMapping(path = "{chatRoomId}/listen")
   public Flux<ServerSentEvent<MessageTo>> listen(@PathVariable UUID chatRoomId)
   {
-    return chatHome
+    return chatHomeService
         .getChatRoomData(chatRoomId)
         .flatMapMany(chatRoomData -> listen(chatRoomData));
   }
@@ -131,6 +131,6 @@ public class ChatBackendController
   @PostMapping("/store")
   public void store()
   {
-    storageStrategy.write(chatHome);
+    storageStrategy.write(chatHomeService);
   }
 }
index 2ff59cb..388a20a 100644 (file)
@@ -6,7 +6,7 @@ import reactor.core.publisher.Mono;
 import java.util.UUID;
 
 
-public interface ChatHome
+public interface ChatHomeService
 {
   Mono<ChatRoomInfo> createChatRoom(UUID id, String name);
 
index a140aa4..2913efe 100644 (file)
@@ -1,6 +1,6 @@
 package de.juplo.kafka.chat.backend.persistence;
 
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
 import de.juplo.kafka.chat.backend.domain.Message;
 import reactor.core.publisher.Flux;
@@ -10,14 +10,14 @@ import java.util.UUID;
 
 public interface StorageStrategy
 {
-  default void write(ChatHome chatHome)
+  default void write(ChatHomeService chatHomeService)
   {
     writeChatRoomInfo(
-        chatHome
+        chatHomeService
             .getChatRoomInfo()
             .doOnNext(chatRoomInfo -> writeChatRoomData(
                 chatRoomInfo.getId(),
-                chatHome
+                chatHomeService
                     .getChatRoomData(chatRoomInfo.getId())
                     .flatMapMany(chatRoomData -> chatRoomData.getMessages()))));
   }
index d2fd731..263a2d5 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend.persistence.inmemory;
 
 import de.juplo.kafka.chat.backend.ChatBackendProperties;
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.persistence.ShardingStrategy;
 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -26,12 +26,12 @@ public class InMemoryServicesConfiguration
       name = "sharding-strategy",
       havingValue = "none",
       matchIfMissing = true)
-  ChatHome noneShardingChatHome(
+  ChatHomeService noneShardingChatHome(
       ChatBackendProperties properties,
       StorageStrategy storageStrategy,
       Clock clock)
   {
-    return new SimpleChatHome(
+    return new SimpleChatHomeService(
         storageStrategy,
         clock,
         properties.getChatroomBufferSize());
@@ -42,22 +42,22 @@ public class InMemoryServicesConfiguration
       prefix = "chat.backend.inmemory",
       name = "sharding-strategy",
       havingValue = "kafkalike")
-  ChatHome kafkalikeShardingChatHome(
+  ChatHomeService kafkalikeShardingChatHome(
       ChatBackendProperties properties,
       StorageStrategy storageStrategy,
       Clock clock)
   {
     int numShards = properties.getInmemory().getNumShards();
-    SimpleChatHome[] chatHomes = new SimpleChatHome[numShards];
+    SimpleChatHomeService[] chatHomes = new SimpleChatHomeService[numShards];
     IntStream
         .of(properties.getInmemory().getOwnedShards())
-        .forEach(shard -> chatHomes[shard] = new SimpleChatHome(
+        .forEach(shard -> chatHomes[shard] = new SimpleChatHomeService(
             shard,
             storageStrategy,
             clock,
             properties.getChatroomBufferSize()));
     ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards);
-    return new ShardedChatHome(chatHomes, strategy);
+    return new ShardedChatHomeService(chatHomes, strategy);
   }
 
   @ConditionalOnProperty(
index 4c8b2fa..09e4684 100644 (file)
@@ -15,15 +15,15 @@ import java.util.stream.Collectors;
 
 
 @Slf4j
-public class ShardedChatHome implements ChatHome
+public class ShardedChatHomeService implements ChatHomeService
 {
-  private final SimpleChatHome[] chatHomes;
+  private final SimpleChatHomeService[] chatHomes;
   private final Set<Integer> ownedShards;
   private final ShardingStrategy shardingStrategy;
 
 
-  public  ShardedChatHome(
-      SimpleChatHome[] chatHomes,
+  public ShardedChatHomeService(
+      SimpleChatHomeService[] chatHomes,
       ShardingStrategy shardingStrategy)
   {
     this.chatHomes = chatHomes;
index 868c01e..d9c3154 100644 (file)
@@ -12,7 +12,7 @@ import java.util.*;
 
 
 @Slf4j
-public class SimpleChatHome implements ChatHome
+public class SimpleChatHomeService implements ChatHomeService
 {
   private final Integer shard;
   private final Map<UUID, ChatRoomInfo> chatRoomInfo;
@@ -22,7 +22,7 @@ public class SimpleChatHome implements ChatHome
 
 
 
-  public SimpleChatHome(
+  public SimpleChatHomeService(
       StorageStrategy storageStrategy,
       Clock clock,
       int bufferSize)
@@ -34,7 +34,7 @@ public class SimpleChatHome implements ChatHome
         bufferSize);
   }
 
-  public SimpleChatHome(
+  public SimpleChatHomeService(
       Integer shard,
       StorageStrategy storageStrategy,
       Clock clock,
index 86b3270..d3321d7 100644 (file)
@@ -1,6 +1,6 @@
 package de.juplo.kafka.chat.backend.persistence.kafka;
 
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.domain.ChatRoomData;
 import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
 import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException;
@@ -15,7 +15,7 @@ import java.util.*;
 
 @RequiredArgsConstructor
 @Slf4j
-public class KafkaChatHome implements ChatHome
+public class KafkaChatHomeService implements ChatHomeService
 {
   private final int numPartitions;
   private final ChatRoomChannel chatRoomChannel;
index df4faed..c4479ce 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend.persistence.kafka;
 
 import de.juplo.kafka.chat.backend.ChatBackendProperties;
-import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.ChatHomeService;
 import de.juplo.kafka.chat.backend.persistence.kafka.messages.AbstractMessageTo;
 import de.juplo.kafka.chat.backend.persistence.kafka.messages.CommandCreateChatRoomTo;
 import de.juplo.kafka.chat.backend.persistence.kafka.messages.EventChatMessageReceivedTo;
@@ -34,11 +34,11 @@ import java.util.Properties;
 public class KafkaServicesConfiguration
 {
   @Bean
-  ChatHome kafkaChatHome(
+  ChatHomeService kafkaChatHome(
       ChatBackendProperties properties,
       ChatRoomChannel chatRoomChannel)
   {
-    return new KafkaChatHome(
+    return new KafkaChatHomeService(
         properties.getKafka().getNumPartitions(),
         chatRoomChannel);
   }
index f831dba..946498a 100644 (file)
@@ -34,7 +34,7 @@ public class ChatBackendControllerTest
   ChatBackendProperties properties;
 
   @MockBean
-  ChatHome chatHome;
+  ChatHomeService chatHomeService;
   @MockBean
   ChatRoomService chatRoomService;
 
@@ -44,7 +44,7 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -64,7 +64,7 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHome.getChatRoomInfo(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
+    when(chatHomeService.getChatRoomInfo(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -85,7 +85,7 @@ public class ChatBackendControllerTest
     UUID chatroomId = UUID.randomUUID();
     String username = "foo";
     Long messageId = 66l;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -111,7 +111,7 @@ public class ChatBackendControllerTest
     UUID chatroomId = UUID.randomUUID();
     String username = "foo";
     Long messageId = 66l;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -134,7 +134,7 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new UnknownChatroomException(chatroomId));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -176,7 +176,7 @@ public class ChatBackendControllerTest
         Clock.systemDefaultZone(),
         chatRoomService,
         8);
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenReturn(Mono.just(chatRoomData));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenReturn(Mono.just(chatRoomData));
     Message existingMessage = new Message(
         key,
         serialNumberExistingMessage,
@@ -226,7 +226,7 @@ public class ChatBackendControllerTest
         Clock.systemDefaultZone(),
         chatRoomService,
         8);
-    when(chatHome.getChatRoomData(any(UUID.class)))
+    when(chatHomeService.getChatRoomData(any(UUID.class)))
         .thenReturn(Mono.just(chatRoomData));
     when(chatRoomService.getMessage(any(Message.MessageKey.class)))
         .thenReturn(Mono.empty());
@@ -260,7 +260,7 @@ public class ChatBackendControllerTest
     // Given
     UUID chatroomId = UUID.randomUUID();
     int shard = 666;
-    when(chatHome.getChatRoomInfo(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
+    when(chatHomeService.getChatRoomInfo(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -280,7 +280,7 @@ public class ChatBackendControllerTest
     // Given
     UUID chatroomId = UUID.randomUUID();
     int shard = 666;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -302,7 +302,7 @@ public class ChatBackendControllerTest
     String username = "foo";
     Long messageId = 66l;
     int shard = 666;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -329,7 +329,7 @@ public class ChatBackendControllerTest
     String username = "foo";
     Long messageId = 66l;
     int shard = 666;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
@@ -353,7 +353,7 @@ public class ChatBackendControllerTest
     // Given
     UUID chatroomId = UUID.randomUUID();
     int shard = 666;
-    when(chatHome.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
+    when(chatHomeService.getChatRoomData(eq(chatroomId))).thenThrow(new ShardNotOwnedException(shard));
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
index 6282643..984da1d 100644 (file)
@@ -17,10 +17,10 @@ import static pl.rzrz.assertj.reactor.Assertions.assertThat;
 
 
 @ExtendWith(SpringExtension.class)
-public abstract class ChatHomeTest
+public abstract class ChatHomeServiceTest
 {
   @Autowired
-  ChatHome chatHome;
+  ChatHomeService chatHomeService;
 
 
   @Test
@@ -32,7 +32,7 @@ public abstract class ChatHomeTest
 
     // When
     Mono<ChatRoomData> mono = Mono
-        .defer(() -> chatHome.getChatRoomData(chatRoomId))
+        .defer(() -> chatHomeService.getChatRoomData(chatRoomId))
         .log("testGetExistingChatroom")
         .retryWhen(Retry
             .backoff(5, Duration.ofSeconds(1))
@@ -51,7 +51,7 @@ public abstract class ChatHomeTest
 
     // When
     Mono<ChatRoomData> mono = Mono
-        .defer(() -> chatHome.getChatRoomData(chatRoomId))
+        .defer(() -> chatHomeService.getChatRoomData(chatRoomId))
         .log("testGetNonExistentChatroom")
         .retryWhen(Retry
             .backoff(5, Duration.ofSeconds(1))
index 65a67b9..5eeac47 100644 (file)
@@ -13,7 +13,7 @@ import java.util.UUID;
 import static pl.rzrz.assertj.reactor.Assertions.assertThat;
 
 
-public abstract class ChatHomeWithShardsTest extends ChatHomeTest
+public abstract class ChatHomeServiceWithShardsTest extends ChatHomeServiceTest
 {
   public static final int NUM_SHARDS = 10;
   public static final int OWNED_SHARD = 2;
@@ -29,7 +29,7 @@ public abstract class ChatHomeWithShardsTest extends ChatHomeTest
 
     // When
     Mono<ChatRoomData> mono = Mono
-        .defer(() -> chatHome.getChatRoomData(chatRoomId))
+        .defer(() -> chatHomeService.getChatRoomData(chatRoomId))
         .log("testGetChatroomForNotOwnedShard")
         .retryWhen(Retry
             .backoff(5, Duration.ofSeconds(1))
index 142f709..3d311a4 100644 (file)
@@ -1,7 +1,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.domain.ChatHomeService;
+import de.juplo.kafka.chat.backend.persistence.inmemory.SimpleChatHomeService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
@@ -21,13 +21,13 @@ public abstract class AbstractInMemoryStorageIT extends AbstractStorageStrategyI
     {
       int bufferSize = 8;
 
-      SimpleChatHome simpleChatHome = new SimpleChatHome(
+      SimpleChatHomeService simpleChatHome = new SimpleChatHomeService(
           getStorageStrategy(),
           clock,
           bufferSize);
 
       @Override
-      public ChatHome getChatHome()
+      public ChatHomeService getChatHome()
       {
         return simpleChatHome;
       }
index e619649..c2149bb 100644 (file)
@@ -13,7 +13,7 @@ import static pl.rzrz.assertj.reactor.Assertions.*;
 @Slf4j
 public abstract class AbstractStorageStrategyIT
 {
-  protected ChatHome chathome;
+  protected ChatHomeService chathome;
 
 
   protected abstract StorageStrategy getStorageStrategy();
@@ -114,6 +114,6 @@ public abstract class AbstractStorageStrategyIT
 
   interface StorageStrategyITConfig
   {
-    ChatHome getChatHome();
+    ChatHomeService getChatHome();
   }
 }
index 8d9036f..0363f5d 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend.persistence.inmemory;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import de.juplo.kafka.chat.backend.domain.ChatHomeWithShardsTest;
+import de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest;
 import de.juplo.kafka.chat.backend.persistence.ShardingStrategy;
 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
 import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy;
@@ -12,21 +12,21 @@ import java.nio.file.Paths;
 import java.time.Clock;
 import java.util.stream.IntStream;
 
-public class ShardedChatHomeTest extends ChatHomeWithShardsTest
+public class ShardedChatHomeServiceTest extends ChatHomeServiceWithShardsTest
 {
   @TestConfiguration
   static class Configuration
   {
     @Bean
-    ShardedChatHome chatHome(
+    ShardedChatHomeService chatHome(
         StorageStrategy storageStrategy,
         Clock clock)
     {
-      SimpleChatHome[] chatHomes = new SimpleChatHome[NUM_SHARDS];
+      SimpleChatHomeService[] chatHomes = new SimpleChatHomeService[NUM_SHARDS];
 
       IntStream
           .of(ownedShards())
-          .forEach(shard -> chatHomes[shard] = new SimpleChatHome(
+          .forEach(shard -> chatHomes[shard] = new SimpleChatHomeService(
               shard,
               storageStrategy,
               clock,
@@ -34,7 +34,7 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTest
 
       ShardingStrategy strategy = new KafkaLikeShardingStrategy(NUM_SHARDS);
 
-      return new ShardedChatHome(chatHomes, strategy);
+      return new ShardedChatHomeService(chatHomes, strategy);
     }
 
     @Bean
index 8be3173..3e3311c 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend.persistence.inmemory;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import de.juplo.kafka.chat.backend.domain.ChatHomeTest;
+import de.juplo.kafka.chat.backend.domain.ChatHomeServiceTest;
 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
 import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy;
 import org.springframework.boot.test.context.TestConfiguration;
@@ -11,17 +11,17 @@ import java.nio.file.Paths;
 import java.time.Clock;
 
 
-public class SimpleChatHomeTest extends ChatHomeTest
+public class SimpleChatHomeServiceTest extends ChatHomeServiceTest
 {
   @TestConfiguration
   static class Configuration
   {
     @Bean
-    SimpleChatHome chatHome(
+    SimpleChatHomeService chatHome(
         StorageStrategy storageStrategy,
         Clock clock)
     {
-      return new SimpleChatHome(
+      return new SimpleChatHomeService(
           storageStrategy,
           clock,
           bufferSize());
index d758a22..3633aa5 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.chat.backend.persistence.kafka;
 
 import de.juplo.kafka.chat.backend.ChatBackendProperties;
-import de.juplo.kafka.chat.backend.domain.ChatHomeWithShardsTest;
+import de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.Consumer;
 import org.apache.kafka.clients.producer.ProducerRecord;
@@ -24,13 +24,13 @@ import java.time.Clock;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
-import static de.juplo.kafka.chat.backend.domain.ChatHomeWithShardsTest.NUM_SHARDS;
-import static de.juplo.kafka.chat.backend.persistence.kafka.KafkaChatHomeTest.TOPIC;
+import static de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest.NUM_SHARDS;
+import static de.juplo.kafka.chat.backend.persistence.kafka.KafkaChatHomeServiceTest.TOPIC;
 
 
 @SpringBootTest(
     classes = {
-        KafkaChatHomeTest.KafkaChatHomeTestConfiguration.class,
+        KafkaChatHomeServiceTest.KafkaChatHomeTestConfiguration.class,
         KafkaServicesConfiguration.class,
         KafkaAutoConfiguration.class,
         TaskExecutionAutoConfiguration.class,
@@ -45,7 +45,7 @@ import static de.juplo.kafka.chat.backend.persistence.kafka.KafkaChatHomeTest.TO
 })
 @EmbeddedKafka(topics = { TOPIC }, partitions = 10)
 @Slf4j
-public class KafkaChatHomeTest extends ChatHomeWithShardsTest
+public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest
 {
   final static String TOPIC = "KAFKA_CHAT_HOME_TEST";