use of org.springframework.data.mongodb.repository.query.MongoQueryExecution.PagingGeoNearExecution in project spring-data-mongodb by spring-projects.
the class MongoQueryExecutionUnitTests method pagingGeoExecutionRetrievesObjectsForPageableOutOfRange.
// DATAMONGO-1464
@Test
public void pagingGeoExecutionRetrievesObjectsForPageableOutOfRange() {
when(findOperationMock.near(any(NearQuery.class))).thenReturn(terminatingGeoMock);
doReturn(new GeoResults<>(Collections.emptyList())).when(terminatingGeoMock).all();
doReturn(terminatingMock).when(findOperationMock).matching(any(Query.class));
ConvertingParameterAccessor accessor = new ConvertingParameterAccessor(converter, new MongoParametersParameterAccessor(queryMethod, new Object[] { POINT, DISTANCE, PageRequest.of(2, 10) }));
PartTreeMongoQuery query = new PartTreeMongoQuery(queryMethod, mongoOperationsMock);
PagingGeoNearExecution execution = new PagingGeoNearExecution(findOperationMock, queryMethod, accessor, query);
execution.execute(new Query());
verify(terminatingGeoMock).all();
verify(terminatingMock).count();
}
use of org.springframework.data.mongodb.repository.query.MongoQueryExecution.PagingGeoNearExecution in project spring-data-mongodb by spring-projects.
the class MongoQueryExecutionUnitTests method pagingGeoExecutionShouldUseCountFromResultWithOffsetAndResultsWithinPageSize.
// DATAMONGO-1464
@Test
public void pagingGeoExecutionShouldUseCountFromResultWithOffsetAndResultsWithinPageSize() {
GeoResult<Person> result = new GeoResult<>(new Person(), DISTANCE);
when(findOperationMock.near(any(NearQuery.class))).thenReturn(terminatingGeoMock);
doReturn(new GeoResults<>(Arrays.asList(result, result, result, result))).when(terminatingGeoMock).all();
ConvertingParameterAccessor accessor = new ConvertingParameterAccessor(converter, new MongoParametersParameterAccessor(queryMethod, new Object[] { POINT, DISTANCE, PageRequest.of(0, 10) }));
PartTreeMongoQuery query = new PartTreeMongoQuery(queryMethod, mongoOperationsMock);
PagingGeoNearExecution execution = new PagingGeoNearExecution(findOperationMock, queryMethod, accessor, query);
execution.execute(new Query());
verify(terminatingGeoMock).all();
}
Aggregations