use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class SetWindowFieldsOperationUnitTests method contextFor.
private static AggregationOperationContext contextFor(@Nullable Class<?> type) {
if (type == null) {
return Aggregation.DEFAULT_CONTEXT;
}
MappingMongoConverter mongoConverter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, new MongoMappingContext());
mongoConverter.afterPropertiesSet();
return new TypeBasedAggregationOperationContext(type, mongoConverter.getMappingContext(), new QueryMapper(mongoConverter));
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterUnitTests method beforeEach.
@BeforeEach
void beforeEach() {
MongoCustomConversions conversions = new MongoCustomConversions();
mappingContext = new MongoMappingContext();
mappingContext.setApplicationContext(context);
mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
mappingContext.afterPropertiesSet();
mappingContext.getPersistentEntity(Address.class);
converter = new MappingMongoConverter(resolver, mappingContext);
converter.setCustomConversions(conversions);
converter.afterPropertiesSet();
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class QueryMapperUnitTests method beforeEach.
@BeforeEach
void beforeEach() {
MongoCustomConversions conversions = new MongoCustomConversions();
this.context = new MongoMappingContext();
this.context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
this.converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, context);
this.converter.setCustomConversions(conversions);
this.converter.afterPropertiesSet();
this.mapper = new QueryMapper(converter);
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class MongoExampleMapperUnitTests method setUp.
@BeforeEach
void setUp() {
this.context = new MongoMappingContext();
this.converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, context);
this.converter.afterPropertiesSet();
this.mapper = new MongoExampleMapper(converter);
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class IndexingIntegrationTests method shouldNotCreateIndexOnIndexingDisabled.
// DATAMONGO-2188
@Test
@DirtiesContext
public void shouldNotCreateIndexOnIndexingDisabled() {
MongoMappingContext context = new MongoMappingContext();
context.setAutoIndexCreation(false);
MongoTemplate template = new MongoTemplate(mongoDbFactory, new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, context));
template.getConverter().getMappingContext().getPersistentEntity(IndexedPerson.class);
assertThat(hasIndex("_firstname", MongoCollectionUtils.getPreferredCollectionName(IndexedPerson.class))).isFalse();
}
Aggregations