|
1 | 1 | /*
|
2 |
| - * Copyright 2014 the original author or authors. |
| 2 | + * Copyright 2014-2015 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
45 | 45 | import org.springframework.data.repository.core.RepositoryMetadata;
|
46 | 46 |
|
47 | 47 | import com.mongodb.BasicDBObjectBuilder;
|
| 48 | +import com.mongodb.util.JSONParseException; |
48 | 49 |
|
49 | 50 | /**
|
50 | 51 | * Unit tests for {@link PartTreeMongoQuery}.
|
@@ -135,6 +136,18 @@ public void shouldAddFullTextParamCorrectlyToDerivedQuery() {
|
135 | 136 | assertThat(query, isTextQuery().searchingFor("search").where(new Criteria("firstname").is("text")));
|
136 | 137 | }
|
137 | 138 |
|
| 139 | + /** |
| 140 | + * @see DATAMONGO-1180 |
| 141 | + */ |
| 142 | + @Test |
| 143 | + public void propagatesRootExceptionForInvalidQuery() { |
| 144 | + |
| 145 | + exception.expect(IllegalStateException.class); |
| 146 | + exception.expectCause(is(org.hamcrest.Matchers.<Throwable> instanceOf(JSONParseException.class))); |
| 147 | + |
| 148 | + deriveQueryFromMethod("findByAge", new Object[] { 1 }); |
| 149 | + } |
| 150 | + |
138 | 151 | private org.springframework.data.mongodb.core.query.Query deriveQueryFromMethod(String method, Object[] args) {
|
139 | 152 |
|
140 | 153 | Class<?>[] types = new Class<?>[args.length];
|
@@ -179,5 +192,8 @@ interface Repo extends MongoRepository<Person, Long> {
|
179 | 192 | Person findPersonByFirstnameAndLastname(String firstname, String lastname);
|
180 | 193 |
|
181 | 194 | Person findPersonByFirstname(String firstname, TextCriteria fullText);
|
| 195 | + |
| 196 | + @Query(fields = "{ 'firstname }") |
| 197 | + Person findByAge(Integer age); |
182 | 198 | }
|
183 | 199 | }
|
0 commit comments