From: Kai Moritz Date: Fri, 18 Aug 2023 13:40:54 +0000 (+0200) Subject: NG X-Git-Tag: rebase--2023-08-18-abends~12 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=404a9a54c6142fc9ab190ae52ac2fd0085b71071;p=demos%2Fkafka%2Fchat NG --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomInfo.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomInfo.java index a739e9fa..6d88be95 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomInfo.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomInfo.java @@ -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 diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageChannel.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageChannel.java index 1abfc7f0..94f6fa6b 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageChannel.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageChannel.java @@ -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[] chatrooms; + private final Map[] 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(); diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageTo.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageTo.java index 41ce00a4..19527f0f 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageTo.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatMessageTo.java @@ -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; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestTo.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestTo.java index b6ad38fb..abc6be80 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestTo.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestTo.java @@ -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; diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestToTest.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestToTest.java index e7b749c4..a917c9f9 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestToTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/CreateChatRoomRequestToTest.java @@ -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); } }