use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class ReactiveStringBasedAggregationUnitTests method setUp.
@BeforeEach
public void setUp() {
converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
when(operations.getConverter()).thenReturn(converter);
when(operations.aggregate(any(TypedAggregation.class), any())).thenReturn(Flux.empty());
when(operations.execute(any())).thenReturn(Flux.empty());
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class PartTreeMongoQueryUnitTests method setUp.
@BeforeEach
void setUp() {
mappingContext = new MongoMappingContext();
MongoConverter converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext);
doReturn(converter).when(mongoOperationsMock).getConverter();
doReturn(findOperationMock).when(mongoOperationsMock).query(any());
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class StringBasedMongoQueryUnitTests method setUp.
@BeforeEach
public void setUp() {
this.converter = new MappingMongoConverter(factory, new MongoMappingContext());
doReturn(findOperation).when(operations).query(any());
doReturn(MongoClientSettings.getDefaultCodecRegistry()).when(operations).execute(any());
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class SessionBoundMongoTemplateTests method getDefaultMongoConverter.
private MongoConverter getDefaultMongoConverter(MongoDatabaseFactory 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.setCodecRegistryProvider(factory);
converter.afterPropertiesSet();
return converter;
}
use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.
the class AggregationUnitTests method shouldNotConvertIncludeExcludeValuesForProjectOperation.
// GH-3898
@Test
void shouldNotConvertIncludeExcludeValuesForProjectOperation() {
MongoMappingContext mappingContext = new MongoMappingContext();
RelaxedTypeBasedAggregationOperationContext context = new RelaxedTypeBasedAggregationOperationContext(WithRetypedIdField.class, mappingContext, new QueryMapper(new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext)));
Document document = project(WithRetypedIdField.class).toDocument(context);
assertThat(document).isEqualTo(new Document("$project", new Document("_id", 1).append("renamed-field", 1)));
}
Aggregations