WIP:test: Simp...
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / persistence / inmemory / ShardedChatHomeTest.java
index d36bf22..9b4bde7 100644 (file)
@@ -11,7 +11,6 @@ import java.nio.file.Paths;
 import java.time.Clock;
 import java.util.stream.IntStream;
 
-
 public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
 {
   @TestConfiguration
@@ -21,13 +20,13 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
     ShardedChatHome chatHome(
         InMemoryChatHomeService chatHomeService)
     {
-      SimpleChatHome[] chatHomes = new SimpleChatHome[numShards()];
+      SimpleChatHome[] chatHomes = new SimpleChatHome[NUM_SHARDS];
 
       IntStream
           .of(ownedShards())
           .forEach(shard -> chatHomes[shard] = new SimpleChatHome(chatHomeService, shard));
 
-      ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards());
+      ShardingStrategy strategy = new KafkaLikeShardingStrategy(NUM_SHARDS);
 
       return new ShardedChatHome(chatHomes, strategy);
     }
@@ -37,7 +36,7 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
         StorageStrategy storageStrategy)
     {
       return new InMemoryChatHomeService(
-          numShards(),
+          NUM_SHARDS,
           ownedShards(),
           storageStrategy.read());
     }
@@ -49,19 +48,14 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
           Paths.get("target", "test-classes", "data", "files"),
           Clock.systemDefaultZone(),
           8,
-          new KafkaLikeShardingStrategy(numShards()),
+          new KafkaLikeShardingStrategy(NUM_SHARDS),
           messageFlux -> new InMemoryChatRoomService(messageFlux),
           new ObjectMapper());
     }
 
-    Integer numShards()
-    {
-      return 10;
-    }
-
     int[] ownedShards()
     {
-      return new int[] { 2 };
+      return new int[] { OWNED_SHARD };
     }
   }
 }