Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#79 added tests for mongodb entity #89

Merged
merged 1 commit into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TestDocument> 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);
}
}
20 changes: 20 additions & 0 deletions src/test/resources/infrastructure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="127.0.0.1"/>
<property name="port" value="27017"/>
</bean>

<bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg name="mongo" ref="mongo"/>
<constructor-arg name="databaseName" value="database"/>
</bean>

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>

</beans>