Skip to content

Commit

Permalink
#79 removed Fongo, fixed tests, implementation done
Browse files Browse the repository at this point in the history
  • Loading branch information
openwms committed Jun 8, 2016
1 parent 5d14bfa commit b6ae821
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/main/java/org/ameba/app/BaseConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.mongodb.config.EnableMongoAuditing;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

/**
* A BaseConfiguration enables auto configuration of Spring Data JPA and MongoDB Auditing and instantiates a JSR-303 ValidatorFactory.
* A BaseConfiguration enables instantiates a JSR-303 ValidatorFactory.
*
* @author <a href="mailto:[email protected]">Heiko Scherrer</a>
* @version 1.1
* @since 1.0
*/
@Configuration
@EnableJpaAuditing
@EnableMongoAuditing
public class BaseConfiguration {

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/ameba/integration/mongodb/BaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.ameba.integration.mongodb;

import java.time.ZonedDateTime;
import java.util.Date;

import org.ameba.integration.TypedEntity;
import org.springframework.data.annotation.CreatedDate;
Expand Down Expand Up @@ -54,14 +54,14 @@ public class BaseEntity implements TypedEntity<String> {
/** Timestamp when the document was inserted. */
@Field(FIELD_CREATED)
@CreatedDate
private ZonedDateTime createDt;
private Date createDt;
/** Field name of the timestamp when the document was inserted. */
public static final String FIELD_CREATED = "_created";

/** Timestamp when the document was updated the last time. */
@Field(FIELD_UPDATED)
@LastModifiedDate
private ZonedDateTime lastModifiedDt;
private Date lastModifiedDt;
/** Field name of the timestamp when the document was updated the last time. */
public static final String FIELD_UPDATED = "_updated";

Expand Down Expand Up @@ -97,7 +97,7 @@ void setPk(String pk) {
*
* @return Creation date
*/
public ZonedDateTime getCreateDt() {
public Date getCreateDt() {
return createDt;
}

Expand All @@ -106,7 +106,7 @@ public ZonedDateTime getCreateDt() {
*
* @return Last modified date
*/
public ZonedDateTime getLastModifiedDt() {
public Date getLastModifiedDt() {
return lastModifiedDt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.ameba.integration.jpa;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.6
*/
@Configuration
@EnableJpaAuditing
@EnableJpaRepositories(basePackageClasses = IntegrationTestConfig.class)
public class IntegrationTestConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import com.mongodb.BasicDBObject;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import org.ameba.app.BaseConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.config.EnableMongoAuditing;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -39,9 +41,10 @@
* @since 1.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "classpath:infrastructure.xml")
@ContextConfiguration(classes = {AbstractMongoDBIntegrationTests.TestConfig.class, BaseConfiguration.class})
public abstract class AbstractMongoDBIntegrationTests {

@EnableMongoAuditing
@Configuration
@EnableMongoRepositories(basePackageClasses = AbstractMongoDBIntegrationTests.class, considerNestedRepositories = true)
static class TestConfig extends AbstractMongoConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void testPk() {
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).getCreateDt()).isNotNull();
assertThat(all.get(0).getLastModifiedDt()).isNotNull();
assertThat(all.get(0)).extracting("ol").contains(0L);
}
}

0 comments on commit b6ae821

Please sign in to comment.