use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method setUp.
@Before
public void setUp() {
doReturn("persons").when(persitentEntityMock).getCollection();
doReturn(persitentEntityMock).when(mappingContextMock).getPersistentEntity(Mockito.any(Class.class));
doReturn(persitentEntityMock).when(mappingContextMock).getRequiredPersistentEntity(Mockito.any(Class.class));
doReturn(Person.class).when(persitentEntityMock).getType();
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mock(MongoDbFactory.class));
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContextMock);
converter.afterPropertiesSet();
doReturn(converter).when(mongoOperationsMock).getConverter();
doReturn(executableFind).when(mongoOperationsMock).query(any());
doReturn(withQueryMock).when(executableFind).as(any());
doReturn(withQueryMock).when(withQueryMock).matching(any());
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class ConvertingParameterAccessorUnitTests method setUp.
@Before
public void setUp() {
this.context = new MongoMappingContext();
this.resolver = new DefaultDbRefResolver(factory);
this.converter = new MappingMongoConverter(resolver, context);
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class ReactiveStringBasedMongoQueryUnitTests method setUp.
@Before
public void setUp() {
when(operations.query(any())).thenReturn(reactiveFind);
this.converter = new MappingMongoConverter(factory, new MongoMappingContext());
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class AbstractMongoConfiguration method mappingMongoConverter.
/**
* Creates a {@link MappingMongoConverter} using the configured {@link #mongoDbFactory()} and
* {@link #mongoMappingContext()}. Will get {@link #customConversions()} applied.
*
* @see #customConversions()
* @see #mongoMappingContext()
* @see #mongoDbFactory()
* @return
* @throws Exception
*/
@Bean
public MappingMongoConverter mappingMongoConverter() throws Exception {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory());
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext());
converter.setCustomConversions(customConversions());
return converter;
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class SessionBoundMongoTemplateTests method getDefaultMongoConverter.
private MongoConverter getDefaultMongoConverter(MongoDbFactory factory) {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
MongoCustomConversions conversions = new MongoCustomConversions(Collections.emptyList());
MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
mappingContext.afterPropertiesSet();
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContext);
converter.setCustomConversions(conversions);
converter.afterPropertiesSet();
return converter;
}
Aggregations