|
|
|
@ -30,6 +30,7 @@ import org.junit.rules.ExpectedException; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.runners.MockitoJUnitRunner; |
|
|
|
import org.mockito.runners.MockitoJUnitRunner; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.mongodb.MongoDbFactory; |
|
|
|
import org.springframework.data.mongodb.MongoDbFactory; |
|
|
|
import org.springframework.data.mongodb.core.MongoOperations; |
|
|
|
import org.springframework.data.mongodb.core.MongoOperations; |
|
|
|
import org.springframework.data.mongodb.core.convert.DbRefResolver; |
|
|
|
import org.springframework.data.mongodb.core.convert.DbRefResolver; |
|
|
|
@ -173,6 +174,14 @@ public class PartTreeMongoQueryUnitTests { |
|
|
|
assertThat(query.getFieldsObject().get("firstname"), is((Object) 1)); |
|
|
|
assertThat(query.getFieldsObject().get("firstname"), is((Object) 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-1729
|
|
|
|
|
|
|
|
public void doesNotCreateFieldsObjectForOpenProjection() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
org.springframework.data.mongodb.core.query.Query query = deriveQueryFromMethod("findAllBy"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(query.getFieldsObject(), is(nullValue())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private org.springframework.data.mongodb.core.query.Query deriveQueryFromMethod(String method, Object... args) { |
|
|
|
private org.springframework.data.mongodb.core.query.Query deriveQueryFromMethod(String method, Object... args) { |
|
|
|
|
|
|
|
|
|
|
|
Class<?>[] types = new Class<?>[args.length]; |
|
|
|
Class<?>[] types = new Class<?>[args.length]; |
|
|
|
@ -233,6 +242,8 @@ public class PartTreeMongoQueryUnitTests { |
|
|
|
|
|
|
|
|
|
|
|
@Query(fields = "{ 'firstname' : 1 }") |
|
|
|
@Query(fields = "{ 'firstname' : 1 }") |
|
|
|
List<Person> findBySex(Sex sex); |
|
|
|
List<Person> findBySex(Sex sex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpenProjection findAllBy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface PersonProjection { |
|
|
|
interface PersonProjection { |
|
|
|
@ -257,4 +268,12 @@ public class PartTreeMongoQueryUnitTests { |
|
|
|
this.lastname = lastname; |
|
|
|
this.lastname = lastname; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface OpenProjection { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String getFirstname(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("#{target.firstname + ' ' + target.lastname}") |
|
|
|
|
|
|
|
String getFullname(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|