From 2f37f03aac7010dcd2ea693c072c4b0102433c1e Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 6 Sep 2023 23:38:28 +0200 Subject: [PATCH] refactor: Moved exceptions into package `exceptions` - Aligned Code --- .../chat/backend/api/ChatBackendControllerAdvice.java | 8 ++++---- .../de/juplo/kafka/chat/backend/domain/ChatRoomData.java | 2 ++ .../domain/exceptions/InvalidUsernameException.java | 2 +- .../domain/exceptions/LoadInProgressException.java | 2 +- .../domain/exceptions/MessageMutationException.java | 3 ++- .../backend/domain/exceptions/ShardNotOwnedException.java | 2 +- .../domain/exceptions/UnknownChatroomException.java | 2 +- .../backend/persistence/inmemory/ShardedChatHome.java | 2 ++ .../chat/backend/persistence/inmemory/SimpleChatHome.java | 1 + .../chat/backend/persistence/kafka/ChatRoomChannel.java | 2 ++ .../chat/backend/persistence/kafka/KafkaChatHome.java | 2 +- .../kafka/chat/backend/api/ChatBackendControllerTest.java | 2 ++ .../de/juplo/kafka/chat/backend/domain/ChatHomeTest.java | 2 ++ .../kafka/chat/backend/domain/ChatHomeWithShardsTest.java | 2 ++ 14 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerAdvice.java b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerAdvice.java index 47b46bc5..90b639ff 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerAdvice.java +++ b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerAdvice.java @@ -1,9 +1,9 @@ package de.juplo.kafka.chat.backend.api; -import de.juplo.kafka.chat.backend.domain.InvalidUsernameException; -import de.juplo.kafka.chat.backend.domain.MessageMutationException; -import de.juplo.kafka.chat.backend.domain.ShardNotOwnedException; -import de.juplo.kafka.chat.backend.domain.UnknownChatroomException; +import de.juplo.kafka.chat.backend.domain.exceptions.InvalidUsernameException; +import de.juplo.kafka.chat.backend.domain.exceptions.MessageMutationException; +import de.juplo.kafka.chat.backend.domain.exceptions.ShardNotOwnedException; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ProblemDetail; diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java index 511b9ade..18ca0bf1 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java @@ -1,5 +1,7 @@ package de.juplo.kafka.chat.backend.domain; +import de.juplo.kafka.chat.backend.domain.exceptions.InvalidUsernameException; +import de.juplo.kafka.chat.backend.domain.exceptions.MessageMutationException; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java index f9a9b122..c79fce20 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.domain; +package de.juplo.kafka.chat.backend.domain.exceptions; import lombok.Getter; diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java index d87e76d3..8a0a81f9 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.domain; +package de.juplo.kafka.chat.backend.domain.exceptions; public class LoadInProgressException extends IllegalStateException diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java index 3f027923..f6db713f 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java @@ -1,5 +1,6 @@ -package de.juplo.kafka.chat.backend.domain; +package de.juplo.kafka.chat.backend.domain.exceptions; +import de.juplo.kafka.chat.backend.domain.Message; import lombok.Getter; diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java index 3b638331..25df317b 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.domain; +package de.juplo.kafka.chat.backend.domain.exceptions; import lombok.Getter; diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java index 714c2207..49fa69d3 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.domain; +package de.juplo.kafka.chat.backend.domain.exceptions; import lombok.Getter; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHome.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHome.java index 2041f530..4c8b2faa 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHome.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHome.java @@ -1,6 +1,8 @@ package de.juplo.kafka.chat.backend.persistence.inmemory; import de.juplo.kafka.chat.backend.domain.*; +import de.juplo.kafka.chat.backend.domain.exceptions.ShardNotOwnedException; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import de.juplo.kafka.chat.backend.persistence.ShardingStrategy; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; 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 c8ddbf9d..868c01e8 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 @@ -1,6 +1,7 @@ package de.juplo.kafka.chat.backend.persistence.inmemory; import de.juplo.kafka.chat.backend.domain.*; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import de.juplo.kafka.chat.backend.persistence.StorageStrategy; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatRoomChannel.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatRoomChannel.java index 45e93ccc..7e95c648 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatRoomChannel.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/ChatRoomChannel.java @@ -1,6 +1,8 @@ package de.juplo.kafka.chat.backend.persistence.kafka; import de.juplo.kafka.chat.backend.domain.*; +import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException; +import de.juplo.kafka.chat.backend.domain.exceptions.ShardNotOwnedException; 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; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHome.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHome.java index 8c749d65..86b32707 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHome.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaChatHome.java @@ -3,7 +3,7 @@ package de.juplo.kafka.chat.backend.persistence.kafka; import de.juplo.kafka.chat.backend.domain.ChatHome; import de.juplo.kafka.chat.backend.domain.ChatRoomData; import de.juplo.kafka.chat.backend.domain.ChatRoomInfo; -import de.juplo.kafka.chat.backend.domain.UnknownChatroomException; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.common.utils.Utils; diff --git a/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java b/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java index a7e40781..f831dbaf 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java @@ -2,6 +2,8 @@ package de.juplo.kafka.chat.backend.api; import de.juplo.kafka.chat.backend.ChatBackendProperties; import de.juplo.kafka.chat.backend.domain.*; +import de.juplo.kafka.chat.backend.domain.exceptions.ShardNotOwnedException; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeTest.java b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeTest.java index 5b50314f..62826432 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeTest.java @@ -1,5 +1,7 @@ package de.juplo.kafka.chat.backend.domain; +import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException; +import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeWithShardsTest.java b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeWithShardsTest.java index c65908c4..65a67b99 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeWithShardsTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeWithShardsTest.java @@ -1,5 +1,7 @@ package de.juplo.kafka.chat.backend.domain; +import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException; +import de.juplo.kafka.chat.backend.domain.exceptions.ShardNotOwnedException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -- 2.20.1