use of org.springframework.data.mongodb.core.convert.MongoCustomConversions in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplate method getDefaultMongoConverter.
private MappingMongoConverter getDefaultMongoConverter() {
MongoCustomConversions conversions = new MongoCustomConversions(Collections.emptyList());
MongoMappingContext context = new MongoMappingContext();
context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
context.afterPropertiesSet();
MappingMongoConverter converter = new MappingMongoConverter(NO_OP_REF_RESOLVER, context);
converter.setCustomConversions(conversions);
converter.setCodecRegistryProvider(this.mongoDatabaseFactory);
converter.afterPropertiesSet();
return converter;
}
use of org.springframework.data.mongodb.core.convert.MongoCustomConversions in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method beforeEach.
@BeforeEach
void beforeEach() {
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslator);
when(factory.getCodecRegistry()).thenReturn(MongoClientSettings.getDefaultCodecRegistry());
when(factory.getMongoDatabase()).thenReturn(Mono.just(db));
when(db.getCollection(any())).thenReturn(collection);
when(db.getCollection(any(), any())).thenReturn(collection);
when(db.runCommand(any(), any(Class.class))).thenReturn(runCommandPublisher);
when(db.createCollection(any(), any(CreateCollectionOptions.class))).thenReturn(runCommandPublisher);
when(collection.withReadPreference(any())).thenReturn(collection);
when(collection.find(any(Class.class))).thenReturn(findPublisher);
when(collection.find(any(Document.class), any(Class.class))).thenReturn(findPublisher);
when(collection.aggregate(anyList())).thenReturn(aggregatePublisher);
when(collection.aggregate(anyList(), any(Class.class))).thenReturn(aggregatePublisher);
when(collection.countDocuments(any(), any(CountOptions.class))).thenReturn(Mono.just(0L));
when(collection.estimatedDocumentCount(any())).thenReturn(Mono.just(0L));
when(collection.updateOne(any(), any(Bson.class), any(UpdateOptions.class))).thenReturn(updateResultPublisher);
when(collection.updateMany(any(Bson.class), any(Bson.class), any())).thenReturn(updateResultPublisher);
when(collection.updateOne(any(), anyList(), any())).thenReturn(updateResultPublisher);
when(collection.updateMany(any(), anyList(), any())).thenReturn(updateResultPublisher);
when(collection.findOneAndUpdate(any(), any(Bson.class), any(FindOneAndUpdateOptions.class))).thenReturn(findAndUpdatePublisher);
when(collection.findOneAndReplace(any(Bson.class), any(), any())).thenReturn(findPublisher);
when(collection.findOneAndDelete(any(), any(FindOneAndDeleteOptions.class))).thenReturn(findPublisher);
when(collection.distinct(anyString(), any(Document.class), any())).thenReturn(distinctPublisher);
when(collection.deleteMany(any(Bson.class), any())).thenReturn(deletePublisher);
when(collection.findOneAndUpdate(any(), any(Bson.class), any(FindOneAndUpdateOptions.class))).thenReturn(findAndUpdatePublisher);
when(collection.mapReduce(anyString(), anyString(), any())).thenReturn(mapReducePublisher);
when(collection.replaceOne(any(Bson.class), any(), any(ReplaceOptions.class))).thenReturn(updateResultPublisher);
when(collection.insertOne(any(Bson.class))).thenReturn(successPublisher);
when(collection.insertMany(anyList())).thenReturn(successPublisher);
when(findPublisher.projection(any())).thenReturn(findPublisher);
when(findPublisher.limit(anyInt())).thenReturn(findPublisher);
when(findPublisher.collation(any())).thenReturn(findPublisher);
when(findPublisher.first()).thenReturn(findPublisher);
when(findPublisher.allowDiskUse(anyBoolean())).thenReturn(findPublisher);
when(aggregatePublisher.allowDiskUse(anyBoolean())).thenReturn(aggregatePublisher);
when(aggregatePublisher.collation(any())).thenReturn(aggregatePublisher);
when(aggregatePublisher.maxTime(anyLong(), any())).thenReturn(aggregatePublisher);
when(aggregatePublisher.first()).thenReturn(findPublisher);
this.mappingContext = new MongoMappingContext();
this.mappingContext.setSimpleTypeHolder(new MongoCustomConversions(Collections.emptyList()).getSimpleTypeHolder());
this.converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext);
this.template = new ReactiveMongoTemplate(factory, converter);
}
Aggregations