From 182a9d3c21cc4a091290a6b616bbec25b7d2d25a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 9 Jan 2023 22:42:37 +0100 Subject: [PATCH] refactor: Moved `FilesStorageStrategy` in its own package -- Rename --- .../kafka/chat/backend/ChatBackendConfiguration.java | 4 ++-- .../storage/files/ChatRoomServiceFactory.java | 2 +- .../storage/files/FilesStorageStrategy.java | 4 ++-- .../persistence/storage/files/JsonFilePublisher.java | 2 +- .../InMemoryWithFilesStorageStrategyIT.java | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendConfiguration.java index 33734a73..dcf2d9f3 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendConfiguration.java @@ -4,7 +4,7 @@ import de.juplo.kafka.chat.backend.domain.ChatHome; import com.fasterxml.jackson.databind.ObjectMapper; import de.juplo.kafka.chat.backend.domain.ChatHomeService; import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatHomeService; -import de.juplo.kafka.chat.backend.persistence.filestorage.FileStorageStrategy; +import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy; import de.juplo.kafka.chat.backend.persistence.StorageStrategy; import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -43,7 +43,7 @@ public class ChatBackendConfiguration Clock clock, ObjectMapper mapper) { - return new FileStorageStrategy( + return new FilesStorageStrategy( Paths.get(properties.getStorageDirectory()), clock, properties.getChatroomBufferSize(), diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/ChatRoomServiceFactory.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/ChatRoomServiceFactory.java index 42c000bb..d06c8f9a 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/ChatRoomServiceFactory.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/ChatRoomServiceFactory.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.persistence.filestorage; +package de.juplo.kafka.chat.backend.persistence.storage.files; import de.juplo.kafka.chat.backend.domain.ChatRoomService; import de.juplo.kafka.chat.backend.domain.Message; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageStrategy.java index 9952117b..e6709709 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageStrategy.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.persistence.filestorage; +package de.juplo.kafka.chat.backend.persistence.storage.files; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; @@ -23,7 +23,7 @@ import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; @RequiredArgsConstructor @Slf4j -public class FileStorageStrategy implements StorageStrategy +public class FilesStorageStrategy implements StorageStrategy { public static final String CHATROOMS_FILENAME = "chatrooms.json"; diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/JsonFilePublisher.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/JsonFilePublisher.java index 3824898f..aec8b367 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/JsonFilePublisher.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/JsonFilePublisher.java @@ -1,4 +1,4 @@ -package de.juplo.kafka.chat.backend.persistence.filestorage; +package de.juplo.kafka.chat.backend.persistence.storage.files; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithFilesStorageStrategyIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithFilesStorageStrategyIT.java index e10aae03..f182c82c 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithFilesStorageStrategyIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithFilesStorageStrategyIT.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.juplo.kafka.chat.backend.domain.ChatHomeService; -import de.juplo.kafka.chat.backend.persistence.filestorage.FileStorageStrategy; +import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy; import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatHomeService; import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService; import lombok.extern.slf4j.Slf4j; @@ -19,22 +19,22 @@ import java.util.function.Supplier; @Slf4j -public class InMemoryWithFileStorageStrategyIT extends AbstractStorageStrategyIT +public class InMemoryWithFilesStorageStrategyIT extends AbstractStorageStrategyIT { final static Path path = Paths.get("target","local-json-files"); final Clock clock; final ObjectMapper mapper; - final FileStorageStrategy storageStrategy; + final FilesStorageStrategy storageStrategy; - public InMemoryWithFileStorageStrategyIT() + public InMemoryWithFilesStorageStrategyIT() { clock = Clock.systemDefaultZone(); mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - storageStrategy = new FileStorageStrategy( + storageStrategy = new FilesStorageStrategy( path, clock, 8, -- 2.20.1