Mongodb morphia (#7316)

* Adding source code for tutorial tracked by BAEL-2971

* Renaming Integration Test as par standard

* Incorporated review comments on the article.

* Moved the morphia module inside persistence-modules/java-mongodb

* Deleted the module morphia.
This commit is contained in:
Kumar Chandrakant 2019-07-16 10:02:17 +05:30 committed by Grzegorz Piwowarek
parent 9572af2804
commit 9566b4d5e4
9 changed files with 47 additions and 98 deletions

View File

@ -1,3 +0,0 @@
### Relevant Articles:
- [Intro to Morphia](http://www.baeldung.com/intro-to-morphia)

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.morphia</groupId>
<artifactId>morphia</artifactId>
<name>morphia</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>dev.morphia.morphia</groupId>
<artifactId>core</artifactId>
<version>${morphia.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
<morphia.version>1.5.3</morphia.version>
</properties>
</project>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,40 +1,49 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>java-mongodb</artifactId>
<version>1.0-SNAPSHOT</version>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>java-mongodb</artifactId>
<version>1.0-SNAPSHOT</version>
<name>java-mongodb</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<dependencies>
<dependencies>
<dependency>
<groupId>de.flapdoodle.embedmongo</groupId>
<artifactId>de.flapdoodle.embedmongo</artifactId>
<version>${flapdoodle.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo.version}</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embedmongo</groupId>
<artifactId>de.flapdoodle.embedmongo</artifactId>
<version>${flapdoodle.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>dev.morphia.morphia</groupId>
<artifactId>core</artifactId>
<version>${morphia.version}</version>
</dependency>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mongo.version>3.10.1</mongo.version>
<flapdoodle.version>1.11</flapdoodle.version>
</properties>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mongo.version>3.10.1</mongo.version>
<flapdoodle.version>1.11</flapdoodle.version>
<morphia.version>1.5.3</morphia.version>
</properties>
</project>

View File

@ -2,6 +2,7 @@ package com.baeldung.morphia;
import static dev.morphia.aggregation.Group.grouping;
import static dev.morphia.aggregation.Group.push;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -51,8 +52,8 @@ public class MorphiaIntegrationTest {
.contains("Learning Java")
.find()
.toList();
assertEquals(books.size(), 1);
assertEquals(books.get(0), book);
assertEquals(1, books.size());
assertEquals(book, books.get(0));
}
@Test
@ -71,8 +72,8 @@ public class MorphiaIntegrationTest {
.contains("Learning Java")
.find()
.toList();
assertEquals(books.get(0)
.getCost(), 4.95);
assertEquals(4.95, books.get(0)
.getCost());
}
@Test
@ -89,7 +90,7 @@ public class MorphiaIntegrationTest {
.contains("Learning Java")
.find()
.toList();
assertEquals(books.size(), 0);
assertEquals(0, books.size());
}
@Test
@ -123,7 +124,7 @@ public class MorphiaIntegrationTest {
assertEquals(books.size(), 1);
assertEquals("Learning Java", books.get(0)
.getTitle());
assertEquals(null, books.get(0)
assertNull(books.get(0)
.getAuthor());
}

View File

@ -558,7 +558,6 @@
<module>tensorflow-java</module>
<module>spring-boot-flowable</module>
<module>spring-security-kerberos</module>
<module>morphia</module>
</modules>
@ -793,7 +792,6 @@
<module>tensorflow-java</module>
<module>spring-boot-flowable</module>
<module>spring-security-kerberos</module>
<module>morphia</module>
</modules>