use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class AbstractPersonRepositoryIntegrationTests method findsPeopleByLocationWithinCircle.
@Test
void findsPeopleByLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave);
List<Person> result = repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170));
assertThat(result).hasSize(1).contains(dave);
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method findsPeopleByLocationWithinCircle.
// DATAMONGO-1444
@Test
void findsPeopleByLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170)).as(StepVerifier::create).expectNext(//
dave).verifyComplete();
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method findsPeopleByPageableLocationWithinCircle.
// DATAMONGO-1444
@Test
void findsPeopleByPageableLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
repository.findByLocationWithin(//
new Circle(-78.99171, 45.738868, 170), PageRequest.of(0, 10)).as(//
StepVerifier::create).expectNext(//
dave).verifyComplete();
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldReadEntityWithGeoCircleCorrectly.
// DATAMONGO-858
@Test
void shouldReadEntityWithGeoCircleCorrectly() {
ClassWithGeoCircle object = new ClassWithGeoCircle();
object.circle = new Circle(new Point(1, 2), 3);
org.bson.Document document = new org.bson.Document();
converter.write(object, document);
ClassWithGeoCircle result = converter.read(ClassWithGeoCircle.class, document);
assertThat(result).isNotNull();
assertThat(result.circle).isEqualTo(result.circle);
}
use of org.springframework.data.geo.Circle in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method shouldWriteEntityWithGeoCircleCorrectly.
// DATAMONGO-858
@Test
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).isNotNull();
assertThat(document.get("circle")).isInstanceOf(org.bson.Document.class);
assertThat(document.get("circle")).isEqualTo((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()));
}
Aggregations