use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class SessionBoundMongoTemplateUnitTests method setUp.
@Before
public void setUp() {
when(client.getDatabase(anyString())).thenReturn(database);
when(codecRegistry.get(any(Class.class))).thenReturn(new BsonValueCodec());
when(database.getCodecRegistry()).thenReturn(codecRegistry);
when(database.getCollection(anyString(), any())).thenReturn(collection);
when(database.listCollectionNames(any(ClientSession.class))).thenReturn(mongoIterable);
when(collection.find(any(ClientSession.class), any(), any())).thenReturn(findIterable);
when(collection.aggregate(any(ClientSession.class), anyList(), any())).thenReturn(aggregateIterable);
when(collection.distinct(any(ClientSession.class), any(), any(), any())).thenReturn(distinctIterable);
when(collection.mapReduce(any(ClientSession.class), any(), any(), any())).thenReturn(mapReduceIterable);
when(findIterable.iterator()).thenReturn(cursor);
when(aggregateIterable.collation(any())).thenReturn(aggregateIterable);
when(aggregateIterable.allowDiskUse(anyBoolean())).thenReturn(aggregateIterable);
when(aggregateIterable.batchSize(anyInt())).thenReturn(aggregateIterable);
when(aggregateIterable.map(any())).thenReturn(aggregateIterable);
when(aggregateIterable.useCursor(anyBoolean())).thenReturn(aggregateIterable);
when(aggregateIterable.into(any())).thenReturn(Collections.emptyList());
when(mongoIterable.iterator()).thenReturn(cursor);
when(distinctIterable.map(any())).thenReturn(distinctIterable);
when(distinctIterable.into(any())).thenReturn(Collections.emptyList());
when(mapReduceIterable.sort(any())).thenReturn(mapReduceIterable);
when(mapReduceIterable.filter(any())).thenReturn(mapReduceIterable);
when(mapReduceIterable.map(any())).thenReturn(mapReduceIterable);
when(mapReduceIterable.iterator()).thenReturn(cursor);
when(cursor.hasNext()).thenReturn(false);
when(findIterable.projection(any())).thenReturn(findIterable);
factory = new SimpleMongoDbFactory(client, "foo");
this.mappingContext = new MongoMappingContext();
this.converter = new MappingMongoConverter(new DefaultDbRefResolver(factory), mappingContext);
this.template = new SessionBoundMongoTemplate(clientSession, new MongoTemplate(factory, converter));
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method setUp.
@Before
public void setUp() {
when(findIterable.iterator()).thenReturn(cursor);
when(factory.getDb()).thenReturn(db);
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslator);
when(db.getCollection(Mockito.any(String.class), eq(Document.class))).thenReturn(collection);
when(db.runCommand(Mockito.any(), Mockito.any(Class.class))).thenReturn(commandResultDocument);
when(collection.find(Mockito.any(org.bson.Document.class), any(Class.class))).thenReturn(findIterable);
when(collection.mapReduce(Mockito.any(), Mockito.any(), eq(Document.class))).thenReturn(mapReduceIterable);
when(collection.count(any(Bson.class), any(CountOptions.class))).thenReturn(1L);
when(collection.aggregate(any(List.class), any())).thenReturn(aggregateIterable);
when(collection.withReadPreference(any())).thenReturn(collection);
when(findIterable.projection(Mockito.any())).thenReturn(findIterable);
when(findIterable.sort(Mockito.any(org.bson.Document.class))).thenReturn(findIterable);
when(findIterable.modifiers(Mockito.any(org.bson.Document.class))).thenReturn(findIterable);
when(findIterable.collation(Mockito.any())).thenReturn(findIterable);
when(findIterable.limit(anyInt())).thenReturn(findIterable);
when(mapReduceIterable.collation(Mockito.any())).thenReturn(mapReduceIterable);
when(mapReduceIterable.sort(Mockito.any())).thenReturn(mapReduceIterable);
when(mapReduceIterable.iterator()).thenReturn(cursor);
when(mapReduceIterable.filter(any())).thenReturn(mapReduceIterable);
when(aggregateIterable.collation(any())).thenReturn(aggregateIterable);
when(aggregateIterable.allowDiskUse(any())).thenReturn(aggregateIterable);
when(aggregateIterable.batchSize(anyInt())).thenReturn(aggregateIterable);
when(aggregateIterable.map(any())).thenReturn(aggregateIterable);
when(aggregateIterable.into(any())).thenReturn(Collections.emptyList());
this.mappingContext = new MongoMappingContext();
this.converter = new MappingMongoConverter(new DefaultDbRefResolver(factory), mappingContext);
this.template = new MongoTemplate(factory, converter);
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method setUp.
@Before
public void setUp() {
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslator);
when(factory.getMongoDatabase()).thenReturn(db);
when(db.getCollection(any())).thenReturn(collection);
when(db.getCollection(any(), any())).thenReturn(collection);
when(db.runCommand(any(), any(Class.class))).thenReturn(runCommandPublisher);
when(collection.find(any(Class.class))).thenReturn(findPublisher);
when(collection.find(any(Document.class), any(Class.class))).thenReturn(findPublisher);
when(findPublisher.projection(any())).thenReturn(findPublisher);
when(findPublisher.limit(anyInt())).thenReturn(findPublisher);
when(findPublisher.collation(any())).thenReturn(findPublisher);
when(findPublisher.first()).thenReturn(findPublisher);
this.mappingContext = new MongoMappingContext();
this.converter = new MappingMongoConverter(new NoOpDbRefResolver(), mappingContext);
this.template = new ReactiveMongoTemplate(factory, converter);
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class TypeBasedAggregationOperationContextUnitTests method setUp.
@Before
public void setUp() {
this.context = new MongoMappingContext();
this.converter = new MappingMongoConverter(dbRefResolver, context);
this.mapper = new QueryMapper(converter);
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class SpringDataMongodbSerializerUnitTests method setUp.
@Before
public void setUp() {
MongoMappingContext context = new MongoMappingContext();
this.converter = new MappingMongoConverter(dbFactory, context);
this.serializer = new SpringDataMongodbSerializer(converter);
}
Aggregations