use of org.springframework.data.geo.Distance in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldWriteEntityWithGeoSphereCorrectly.
// DATAMONGO-858
@Test
public void shouldWriteEntityWithGeoSphereCorrectly() {
ClassWithGeoSphere object = new ClassWithGeoSphere();
Sphere sphere = new Sphere(new Point(1, 2), 3);
Distance radius = sphere.getRadius();
object.sphere = sphere;
org.bson.Document document = new org.bson.Document();
converter.write(object, document);
assertThat(document, is(notNullValue()));
assertThat(document.get("sphere"), is(instanceOf(org.bson.Document.class)));
assertThat(document.get("sphere"), is((Object) new org.bson.Document("center", new org.bson.Document("x", sphere.getCenter().getX()).append("y", sphere.getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString())));
}
use of org.springframework.data.geo.Distance in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldWriteEntityWithGeoCircleCorrectly.
// DATAMONGO-858
@Test
public void shouldWriteEntityWithGeoCircleCorrectly() {
ClassWithGeoCircle object = new ClassWithGeoCircle();
Circle circle = new Circle(new Point(1, 2), 3);
Distance radius = circle.getRadius();
object.circle = circle;
org.bson.Document document = new org.bson.Document();
converter.write(object, document);
assertThat(document, is(notNullValue()));
assertThat(document.get("circle"), is(instanceOf(org.bson.Document.class)));
assertThat(document.get("circle"), is((Object) new org.bson.Document("center", new org.bson.Document("x", circle.getCenter().getX()).append("y", circle.getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString())));
}
use of org.springframework.data.geo.Distance in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldWriteEntityWithGeoSphereWithMetricDistanceCorrectly.
// DATAMONGO-858
@Test
public void shouldWriteEntityWithGeoSphereWithMetricDistanceCorrectly() {
ClassWithGeoSphere object = new ClassWithGeoSphere();
Sphere sphere = new Sphere(new Point(1, 2), new Distance(3, Metrics.KILOMETERS));
Distance radius = sphere.getRadius();
object.sphere = sphere;
org.bson.Document document = new org.bson.Document();
converter.write(object, document);
assertThat(document, is(notNullValue()));
assertThat(document.get("sphere"), is(instanceOf(org.bson.Document.class)));
assertThat(document.get("sphere"), is((Object) new org.bson.Document("center", new org.bson.Document("x", sphere.getCenter().getX()).append("y", sphere.getCenter().getY())).append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString())));
}
Aggregations