use of org.springframework.data.geo.Box in project spring-data-mongodb by spring-projects.
the class GeoConvertersUnitTests method convertsBoxToDocumentAndBackCorrectly.
// DATAMONGO-858
@Test
public void convertsBoxToDocumentAndBackCorrectly() {
Box box = new Box(new Point(1, 2), new Point(3, 4));
Document document = BoxToDocumentConverter.INSTANCE.convert(box);
Box result = DocumentToBoxConverter.INSTANCE.convert(document);
assertThat(result, is(box));
assertThat(result.getClass().equals(Box.class), is(true));
}
use of org.springframework.data.geo.Box in project spring-data-mongodb by spring-projects.
the class GeoConvertersUnitTests method convertsGeoCommandToDocumentCorrectly.
// DATAMONGO-858
@Test
public void convertsGeoCommandToDocumentCorrectly() {
Box box = new Box(new double[] { 1, 2 }, new double[] { 3, 4 });
GeoCommand cmd = new GeoCommand(box);
Document document = GeoCommandToDocumentConverter.INSTANCE.convert(cmd);
assertThat(document, is(notNullValue()));
List<Object> boxObject = (List<Object>) document.get("$box");
assertThat(boxObject, is((Object) Arrays.asList(GeoConverters.toList(box.getFirst()), GeoConverters.toList(box.getSecond()))));
}
use of org.springframework.data.geo.Box in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldReadEntityWithGeoBoxCorrectly.
// DATAMONGO-858
@Test
public void shouldReadEntityWithGeoBoxCorrectly() {
ClassWithGeoBox object = new ClassWithGeoBox();
object.box = new Box(new Point(1, 2), new Point(3, 4));
org.bson.Document document = new org.bson.Document();
converter.write(object, document);
ClassWithGeoBox result = converter.read(ClassWithGeoBox.class, document);
assertThat(result, is(notNullValue()));
assertThat(result.box, is(object.box));
}
use of org.springframework.data.geo.Box in project spring-data-mongodb by spring-projects.
the class AbstractPersonRepositoryIntegrationTests method findsPeopleByLocationWithinBox.
@Test
public void findsPeopleByLocationWithinBox() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave);
Box box = new Box(new Point(-78.99171, 35.738868), new Point(-68.99171, 45.738868));
List<Person> result = repository.findByLocationWithin(box);
assertThat(result.size(), is(1));
assertThat(result, hasItem(dave));
}
use of org.springframework.data.geo.Box in project spring-data-mongodb by spring-projects.
the class AbstractGeoSpatialTests method withinBox.
@Test
public void withinBox() {
Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404));
List<Venue> venues = template.find(query(where("location").within(box)), Venue.class);
assertThat(venues.size(), is(4));
}
Aggregations