Search in sources :

Example 1 with GeoJsonLineString

use of org.springframework.data.mongodb.core.geo.GeoJsonLineString in project spring-data-mongodb by spring-projects.

the class MongoQueryCreatorUnitTests method queryShouldThrowExceptionWhenArgumentDoesNotMatchDeclaration.

// DATAMONGO-1588
@Test
public void queryShouldThrowExceptionWhenArgumentDoesNotMatchDeclaration() {
    expection.expect(IllegalArgumentException.class);
    expection.expectMessage("Expected parameter type of " + Point.class);
    PartTree tree = new PartTree("findByLocationNear", User.class);
    ConvertingParameterAccessor accessor = getAccessor(converter, new GeoJsonLineString(new Point(-74.044502D, 40.689247D), new Point(-73.997330D, 40.730824D)));
    new MongoQueryCreator(tree, accessor, context).createQuery();
}
Also used : GeoJsonLineString(org.springframework.data.mongodb.core.geo.GeoJsonLineString) Point(org.springframework.data.geo.Point) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint) PartTree(org.springframework.data.repository.query.parser.PartTree) Test(org.junit.Test)

Example 2 with GeoJsonLineString

use of org.springframework.data.mongodb.core.geo.GeoJsonLineString in project spring-data-mongodb by spring-projects.

the class CriteriaTests method intersectsShouldWrapGeoJsonTypeInGeometryCorrectly.

// DATAMONGO-1134
@Test
public void intersectsShouldWrapGeoJsonTypeInGeometryCorrectly() {
    GeoJsonLineString lineString = new GeoJsonLineString(new Point(0, 0), new Point(10, 10));
    Document document = new Criteria("foo").intersects(lineString).getCriteriaObject();
    assertThat(document, isBsonObject().containing("foo.$geoIntersects.$geometry", lineString));
}
Also used : GeoJsonLineString(org.springframework.data.mongodb.core.geo.GeoJsonLineString) Point(org.springframework.data.geo.Point) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint) Document(org.bson.Document) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Point (org.springframework.data.geo.Point)2 GeoJsonLineString (org.springframework.data.mongodb.core.geo.GeoJsonLineString)2 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)2 Document (org.bson.Document)1 PartTree (org.springframework.data.repository.query.parser.PartTree)1