use of org.springframework.data.mongodb.repository.query.ReactiveMongoQueryExecution.GeoNearExecution in project spring-data-mongodb by spring-projects.
the class ReactiveMongoQueryExecutionUnitTests method geoNearExecutionShouldApplyQuerySettings.
// DATAMONGO-1444
@Test
public void geoNearExecutionShouldApplyQuerySettings() throws Exception {
Method geoNear = ClassUtils.getMethod(GeoRepo.class, "geoNear");
Query query = new Query();
when(parameterAccessor.getGeoNearLocation()).thenReturn(new Point(1, 2));
when(parameterAccessor.getDistanceRange()).thenReturn(new Range<>(new Distance(10), new Distance(15)));
when(parameterAccessor.getPageable()).thenReturn(PageRequest.of(1, 10));
new GeoNearExecution(operations, parameterAccessor, ClassTypeInformation.fromReturnTypeOf(geoNear)).execute(query, Person.class, "person");
ArgumentCaptor<NearQuery> queryArgumentCaptor = ArgumentCaptor.forClass(NearQuery.class);
verify(operations).geoNear(queryArgumentCaptor.capture(), eq(Person.class), eq("person"));
NearQuery nearQuery = queryArgumentCaptor.getValue();
assertThat(nearQuery.toDocument().get("near"), is(equalTo(Arrays.asList(1d, 2d))));
assertThat(nearQuery.getSkip(), is(10L));
assertThat(nearQuery.getMinDistance(), is(equalTo(new Distance(10))));
assertThat(nearQuery.getMaxDistance(), is(equalTo(new Distance(15))));
}
use of org.springframework.data.mongodb.repository.query.ReactiveMongoQueryExecution.GeoNearExecution in project spring-data-mongodb by spring-projects.
the class ReactiveMongoQueryExecutionUnitTests method geoNearExecutionShouldApplyMinimalSettings.
// DATAMONGO-1444
@Test
public void geoNearExecutionShouldApplyMinimalSettings() throws Exception {
Method geoNear = ClassUtils.getMethod(GeoRepo.class, "geoNear");
Query query = new Query();
when(parameterAccessor.getPageable()).thenReturn(Pageable.unpaged());
when(parameterAccessor.getGeoNearLocation()).thenReturn(new Point(1, 2));
when(parameterAccessor.getDistanceRange()).thenReturn(new Range<>(null, null));
new GeoNearExecution(operations, parameterAccessor, ClassTypeInformation.fromReturnTypeOf(geoNear)).execute(query, Person.class, "person");
ArgumentCaptor<NearQuery> queryArgumentCaptor = ArgumentCaptor.forClass(NearQuery.class);
verify(operations).geoNear(queryArgumentCaptor.capture(), eq(Person.class), eq("person"));
NearQuery nearQuery = queryArgumentCaptor.getValue();
assertThat(nearQuery.toDocument().get("near"), is(equalTo(Arrays.asList(1d, 2d))));
assertThat(nearQuery.getSkip(), is(0L));
assertThat(nearQuery.getMinDistance(), is(nullValue()));
assertThat(nearQuery.getMaxDistance(), is(nullValue()));
}
Aggregations