Search in sources :

Example 51 with PartTree

use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.

the class MongoQueryCreatorUnitTests method queryShouldAcceptSubclassOfDeclaredArgument.

// DATAMONGO-1588
@Test
public void queryShouldAcceptSubclassOfDeclaredArgument() {
    PartTree tree = new PartTree("findByLocationNear", User.class);
    ConvertingParameterAccessor accessor = getAccessor(converter, new GeoJsonPoint(-74.044502D, 40.689247D));
    Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
    assertThat(query.getQueryObject().containsKey("location"), is(true));
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) PartTree(org.springframework.data.repository.query.parser.PartTree) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint) Test(org.junit.Test)

Aggregations

PartTree (org.springframework.data.repository.query.parser.PartTree)51 Test (org.junit.Test)48 Query (org.springframework.data.mongodb.core.query.Query)44 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)7 Point (org.springframework.data.geo.Point)6 Distance (org.springframework.data.geo.Distance)3 Part (org.springframework.data.repository.query.parser.Part)2 Method (java.lang.reflect.Method)1 Document (org.bson.Document)1 ObjectId (org.bson.types.ObjectId)1 NotNull (org.jetbrains.annotations.NotNull)1 Sort (org.springframework.data.domain.Sort)1 Direction (org.springframework.data.domain.Sort.Direction)1 Order (org.springframework.data.domain.Sort.Order)1 Polygon (org.springframework.data.geo.Polygon)1 Shape (org.springframework.data.geo.Shape)1 Person (org.springframework.data.mongodb.core.Person)1 GeoJsonLineString (org.springframework.data.mongodb.core.geo.GeoJsonLineString)1 Index (org.springframework.data.mongodb.core.index.Index)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1