use of com.mongodb.client.MapReduceIterable in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptions.
// DATAMONGO-1334
@Test
public void mapReduceShouldPickUpLimitFromOptions() {
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(Mockito.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'}");
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.MapReduceIterable in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromQuery.
// DATAMONGO-1334
@Test
public void mapReduceShouldPickUpLimitFromQuery() {
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(Mockito.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){}", Wrapper.class);
verify(output, times(1)).limit(100);
}
use of com.mongodb.client.MapReduceIterable in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldUseZeroAsDefaultLimit.
// DATAMONGO-1334
@Test
@Ignore("TODO: mongo3 - a bit hard to tests with the immutable object stuff")
public void mapReduceShouldUseZeroAsDefaultLimit() {
MongoCursor cursor = mock(MongoCursor.class);
MapReduceIterable output = mock(MapReduceIterable.class);
when(output.limit(anyInt())).thenReturn(output);
when(output.sort(Mockito.any(Document.class))).thenReturn(output);
when(output.filter(Mockito.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.MapReduceIterable in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptionsWhenQueryIsNotPresent.
// DATAMONGO-1334
@Test
public 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);
}
use of com.mongodb.client.MapReduceIterable in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method mapReduceShouldPickUpLimitFromOptionsEvenWhenQueryDefinesItDifferently.
// DATAMONGO-1334
@Test
public 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(Mockito.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);
}
Aggregations