Search in sources :

Example 1 with PagingGeoNearExecution

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();
}
Also used : NearQuery(org.springframework.data.mongodb.core.query.NearQuery) FindWithQuery(org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) Query(org.springframework.data.mongodb.core.query.Query) PagingGeoNearExecution(org.springframework.data.mongodb.repository.query.MongoQueryExecution.PagingGeoNearExecution) Test(org.junit.Test)

Example 2 with PagingGeoNearExecution

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();
}
Also used : NearQuery(org.springframework.data.mongodb.core.query.NearQuery) PagingGeoNearExecution(org.springframework.data.mongodb.repository.query.MongoQueryExecution.PagingGeoNearExecution) FindWithQuery(org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) Query(org.springframework.data.mongodb.core.query.Query) GeoResult(org.springframework.data.geo.GeoResult) Person(org.springframework.data.mongodb.repository.Person) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FindWithQuery (org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery)2 NearQuery (org.springframework.data.mongodb.core.query.NearQuery)2 Query (org.springframework.data.mongodb.core.query.Query)2 PagingGeoNearExecution (org.springframework.data.mongodb.repository.query.MongoQueryExecution.PagingGeoNearExecution)2 GeoResult (org.springframework.data.geo.GeoResult)1 Person (org.springframework.data.mongodb.repository.Person)1