WIP
authorKai Moritz <kai@juplo.de>
Tue, 10 Jan 2023 19:57:44 +0000 (20:57 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 10 Jan 2023 19:57:44 +0000 (20:57 +0100)
pom.xml
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomTo.java
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageTo.java
src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java

diff --git a/pom.xml b/pom.xml
index 7b32556..27a6236 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,7 @@
        <properties>
                <java.version>17</java.version>
                <assertj-reactor.version>1.0.8</assertj-reactor.version>
+               <mongodb.version>4.7.2</mongodb.version>
        </properties>
        <dependencyManagement>
                <dependencies>
index f4f3ac6..bc3863b 100644 (file)
@@ -4,6 +4,7 @@ import de.juplo.kafka.chat.backend.domain.ChatRoom;
 import lombok.*;
 import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.util.List;
 
@@ -14,6 +15,7 @@ import java.util.List;
 @Setter(AccessLevel.PACKAGE)
 @EqualsAndHashCode(of = { "id" })
 @ToString(of = { "id", "name" })
+@Document
 public class ChatRoomTo
 {
   @Id
index 8e37166..7a45799 100644 (file)
@@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.persistence.storage.mongodb;
 
 import de.juplo.kafka.chat.backend.domain.Message;
 import lombok.*;
+import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.time.LocalDateTime;
 import java.util.regex.Matcher;
@@ -14,6 +15,7 @@ import java.util.regex.Pattern;
 @Setter(AccessLevel.PACKAGE)
 @EqualsAndHashCode(of = { "user", "id" })
 @ToString(of = { "user", "id" })
+@Document
 class MessageTo
 {
   final static Pattern SPLIT_ID = Pattern.compile("^([a-z-]+)--([0-9]+)$");
index 66f06d4..d3d0c56 100644 (file)
@@ -81,8 +81,6 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg
   @Container
   private static final GenericContainer CONTAINER =
       new GenericContainer("mongo:6")
-          .withEnv("MONGO_INITDB_ROOT_USERNAME", "mongo")
-          .withEnv("MONGO_INITDB_ROOT_PASSWORD", "mongo")
           .withEnv("MONGO_INITDB_DATABASE", "test")
           .withExposedPorts(MONGODB_PORT);
 
@@ -96,8 +94,6 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg
           applicationContext,
           "spring.data.mongodb.host=localhost",
           "spring.data.mongodb.port=" + CONTAINER.getMappedPort(MONGODB_PORT),
-          "spring.data.mongodb.username=mongo",
-          "spring.data.mongodb.password=mongo",
           "spring.data.mongodb.database=test");
 
       Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log);