From ea4f5a09c7c2983b1187aad29031e83669d672fd Mon Sep 17 00:00:00 2001 From: Heiko Scherrer Date: Tue, 7 Jun 2016 22:39:22 +0200 Subject: [PATCH] #79 added tests for mongodb entity --- .travis.yml | 12 +++++++++++ .../AbstractMongoDBIntegrationTests.java | 3 ++- .../integration/mongodb/BaseEntityTest.java | 15 +++++++++++--- src/test/resources/infrastructure.xml | 20 +++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/infrastructure.xml diff --git a/.travis.yml b/.travis.yml index 9bcf999..bce06b8 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,15 @@ language: java + jdk: - oraclejdk8 + +before_script: + - mongod --version + +addons: + apt: + sources: + - mongodb-3.2-precise + packages: + - mongodb-org-server + - mongodb-org-shell diff --git a/src/test/java/org/ameba/integration/mongodb/AbstractMongoDBIntegrationTests.java b/src/test/java/org/ameba/integration/mongodb/AbstractMongoDBIntegrationTests.java index 02f7fb3..a8fcbe4 100644 --- a/src/test/java/org/ameba/integration/mongodb/AbstractMongoDBIntegrationTests.java +++ b/src/test/java/org/ameba/integration/mongodb/AbstractMongoDBIntegrationTests.java @@ -39,7 +39,8 @@ * @since 1.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = AbstractMongoDBIntegrationTests.TestConfig.class) +//@EnableMongoAuditing +@ContextConfiguration(/*classes = AbstractMongoDBIntegrationTests.TestConfig.class, */locations = "classpath:infrastructure.xml") public abstract class AbstractMongoDBIntegrationTests { @Configuration diff --git a/src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java b/src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java index 71a2682..90f1482 100644 --- a/src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java +++ b/src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java @@ -15,8 +15,11 @@ */ package org.ameba.integration.mongodb; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + import org.ameba.app.BaseConfiguration; -import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; @@ -35,11 +38,17 @@ public class BaseEntityTest extends AbstractMongoDBIntegrationTests { @Autowired private MongoOperations template; - @Ignore("Need to be fiexed to run with Mongo, or have a deeper look at the SDM tests that are provided") @Test public void testPk() { TestDocument td = new TestDocument(); - template.save(td); + template.insert(td); + List all = template.findAll(TestDocument.class); + assertThat(all).hasSize(1); + assertThat(all.get(0).isNew()).isFalse(); + assertThat(all.get(0).getPk()).isNotNull(); +// assertThat(all.get(0).getCreateDt()).isNotNull(); +// assertThat(all.get(0).getLastModifiedDt()).isNotNull(); + assertThat(all.get(0)).extracting("ol").contains(0L); } } diff --git a/src/test/resources/infrastructure.xml b/src/test/resources/infrastructure.xml new file mode 100644 index 0000000..2cd73b7 --- /dev/null +++ b/src/test/resources/infrastructure.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +