use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldUseZeroAsDefaultLimit.
// DATAMONGO-1334
@Test
@Disabled("TODO: mongo3 - a bit hard to tests with the immutable object stuff")
void mapReduceShouldUseZeroAsDefaultLimit() {
MongoCursor cursor = mock(MongoCursor.class);
MapReduceIterable output = mock(MapReduceIterable.class);
when(output.limit(anyInt())).thenReturn(output);
when(output.sort(any(Document.class))).thenReturn(output);
when(output.filter(any(Document.class))).thenReturn(output);
when(output.iterator()).thenReturn(cursor);
when(cursor.hasNext()).thenReturn(false);
when(collection.mapReduce(anyString(), anyString())).thenReturn(output);
Query query = new BasicQuery("{'foo':'bar'}");
template.mapReduce(query, "collection", "function(){}", "function(key,values){}", Wrapper.class);
verify(output, times(1)).limit(1);
}
use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptionsEvenWhenQueryDefinesItDifferently.
// DATAMONGO-1334
@Test
void mapReduceShouldPickUpLimitFromOptionsEvenWhenQueryDefinesItDifferently() {
MongoCursor cursor = mock(MongoCursor.class);
MapReduceIterable output = mock(MapReduceIterable.class);
when(output.limit(anyInt())).thenReturn(output);
when(output.sort(any())).thenReturn(output);
when(output.filter(any(Document.class))).thenReturn(output);
when(output.iterator()).thenReturn(cursor);
when(cursor.hasNext()).thenReturn(false);
when(collection.mapReduce(anyString(), anyString(), eq(Document.class))).thenReturn(output);
Query query = new BasicQuery("{'foo':'bar'}");
query.limit(100);
template.mapReduce(query, "collection", "function(){}", "function(key,values){}", new MapReduceOptions().limit(1000), Wrapper.class);
verify(output, times(1)).limit(1000);
}
use of com.mongodb.client.MongoCursor in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptionsWhenQueryIsNotPresent.
// DATAMONGO-1334
@Test
void mapReduceShouldPickUpLimitFromOptionsWhenQueryIsNotPresent() {
MongoCursor cursor = mock(MongoCursor.class);
MapReduceIterable output = mock(MapReduceIterable.class);
when(output.limit(anyInt())).thenReturn(output);
when(output.sort(any())).thenReturn(output);
when(output.filter(any())).thenReturn(output);
when(output.iterator()).thenReturn(cursor);
when(cursor.hasNext()).thenReturn(false);
when(collection.mapReduce(anyString(), anyString(), eq(Document.class))).thenReturn(output);
template.mapReduce("collection", "function(){}", "function(key,values){}", new MapReduceOptions().limit(1000), Wrapper.class);
verify(output, times(1)).limit(1000);
}
Aggregations