Skip to content

Commit ceef18d

Browse files
committedJul 3, 2013
DATAMONGO-671 - Added integration tests to show lookups by date are working.
1 parent 4f57712 commit ceef18d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 

‎spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ protected void cleanDb() {
149149
template.dropCollection(Sample.class);
150150
template.dropCollection(MyPerson.class);
151151
template.dropCollection(TypeWithFieldAnnotation.class);
152+
template.dropCollection(TypeWithDate.class);
152153
template.dropCollection("collection");
153154
template.dropCollection("personX");
154155
}
@@ -1642,6 +1643,24 @@ public void updateConsidersMappingAnnotations() {
16421643
assertThat(result.emailAddress, is("new"));
16431644
}
16441645

1646+
/**
1647+
* @see DATAMONGO-671
1648+
*/
1649+
@Test
1650+
public void findsEntityByDateReference() {
1651+
1652+
TypeWithDate entity = new TypeWithDate();
1653+
entity.date = new Date();
1654+
1655+
template.save(entity);
1656+
1657+
Query query = query(where("date").lt(new Date()));
1658+
List<TypeWithDate> result = template.find(query, TypeWithDate.class);
1659+
1660+
assertThat(result, hasSize(1));
1661+
assertThat(result.get(0).date, is(notNullValue()));
1662+
}
1663+
16451664
static class MyId {
16461665

16471666
String first;
@@ -1721,4 +1740,10 @@ static class TypeWithFieldAnnotation {
17211740
@Id ObjectId id;
17221741
@Field("email") String emailAddress;
17231742
}
1743+
1744+
static class TypeWithDate {
1745+
1746+
@Id String id;
1747+
Date date;
1748+
}
17241749
}

0 commit comments

Comments
 (0)
Please sign in to comment.