NG
authorKai Moritz <kai@juplo.de>
Fri, 18 Aug 2023 13:40:54 +0000 (15:40 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 18 Aug 2023 15:18:41 +0000 (17:18 +0200)
src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomInfo.java
src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageChannel.java
src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageTo.java
src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestTo.java
src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestToTest.java

index a739e9f..6d88be9 100644 (file)
@@ -8,7 +8,7 @@ import lombok.ToString;
 import java.util.UUID;
 
 
-@RequiredArgsConstructor(staticName = "of")
+@RequiredArgsConstructor
 @EqualsAndHashCode(of = { "id" })
 @ToString(of = { "id", "name", "shard" })
 public class ChatRoomInfo
index 1abfc7f..94f6fa6 100644 (file)
@@ -34,7 +34,7 @@ public class ChatMessageChannel implements Runnable, ConsumerRebalanceListener
   private final boolean[] isShardOwned;
   private final long[] currentOffset;
   private final long[] nextOffset;
-  private final Map<UUID, ChatRoomInfo>[] chatrooms;
+  private final Map<UUID, ChatRoom>[] chatrooms;
 
   private boolean running;
   @Getter
@@ -308,7 +308,7 @@ public class ChatMessageChannel implements Runnable, ConsumerRebalanceListener
     Message.MessageKey key = Message.MessageKey.of(chatMessageTo.getUser(), chatMessageTo.getId());
     Message message = new Message(key, offset, timestamp, chatMessageTo.getText());
 
-    ChatRoomInfo chatRoom = chatrooms[partition].get(chatRoomId);
+    ChatRoom chatRoom = chatrooms[partition].get(chatRoomId);
     KafkaChatRoomService kafkaChatRoomService =
         (KafkaChatRoomService) chatRoom.getChatRoomService();
 
@@ -333,7 +333,7 @@ public class ChatMessageChannel implements Runnable, ConsumerRebalanceListener
   }
 
 
-  private void putChatRoom(ChatRoomInfo chatRoom)
+  private void putChatRoom(ChatRoom chatRoom)
   {
     Integer partition = chatRoom.getShard();
     UUID chatRoomId = chatRoom.getId();
index 41ce00a..19527f0 100644 (file)
@@ -1,12 +1,15 @@
 package de.juplo.kafka.chat.backend.persistence.kafka;
 
 import de.juplo.kafka.chat.backend.domain.Message;
-import lombok.Data;
+import lombok.*;
 
 import java.time.LocalDateTime;
 
 
-@Data
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
 public class ChatMessageTo extends AbstractTo
 {
   private String user;
index b6ad38f..abc6be8 100644 (file)
@@ -1,13 +1,12 @@
 package de.juplo.kafka.chat.backend.persistence.kafka;
 
-import de.juplo.kafka.chat.backend.domain.ChatRoom;
-import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
-import lombok.Data;
+import lombok.*;
 
-import java.util.UUID;
 
-
-@Data
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
 public class CreateChatRoomRequestTo extends AbstractTo
 {
   private String name;
index e7b749c..a917c9f 100644 (file)
@@ -13,9 +13,7 @@ public class CreateChatRoomRequestToTest
 {
   final String json = """
   {
-    "id": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
     "name": "Foo-Room!",
-    "shard": 666
   }""";
 
   ObjectMapper mapper;
@@ -32,8 +30,6 @@ public class CreateChatRoomRequestToTest
   public void testDeserialization() throws Exception
   {
     CreateChatRoomRequestTo message = mapper.readValue(json, CreateChatRoomRequestTo.class);
-    assertThat(message.getId()).isEqualTo("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
     assertThat(message.getName()).isEqualTo("Foo-Room!");
-    assertThat(message.getShard()).isEqualTo(666);
   }
 }