From ceef18d7a4b60fa0ffe20a4669a739b32fca0588 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 3 Jul 2013 17:48:04 +0200 Subject: [PATCH] DATAMONGO-671 - Added integration tests to show lookups by date are working. --- .../data/mongodb/core/MongoTemplateTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java index 05c13ffe9..cc365417f 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java @@ -149,6 +149,7 @@ public class MongoTemplateTests { template.dropCollection(Sample.class); template.dropCollection(MyPerson.class); template.dropCollection(TypeWithFieldAnnotation.class); + template.dropCollection(TypeWithDate.class); template.dropCollection("collection"); template.dropCollection("personX"); } @@ -1642,6 +1643,24 @@ public class MongoTemplateTests { assertThat(result.emailAddress, is("new")); } + /** + * @see DATAMONGO-671 + */ + @Test + public void findsEntityByDateReference() { + + TypeWithDate entity = new TypeWithDate(); + entity.date = new Date(); + + template.save(entity); + + Query query = query(where("date").lt(new Date())); + List result = template.find(query, TypeWithDate.class); + + assertThat(result, hasSize(1)); + assertThat(result.get(0).date, is(notNullValue())); + } + static class MyId { String first; @@ -1721,4 +1740,10 @@ public class MongoTemplateTests { @Id ObjectId id; @Field("email") String emailAddress; } + + static class TypeWithDate { + + @Id String id; + Date date; + } }