use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class ProjectionOperationUnitTests method typeProjectionShouldMapFieldNames.
// DATAMONGO-2200
@Test
void typeProjectionShouldMapFieldNames() {
MongoMappingContext mappingContext = new MongoMappingContext();
MongoConverter converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext);
Document document = Aggregation.project(BookRenamed.class).toDocument(new TypeBasedAggregationOperationContext(Book.class, mappingContext, new QueryMapper(converter)));
Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT);
//
assertThat(projectClause).hasSize(//
2).containsEntry("ti_tl_e", //
1).containsEntry("author", 1);
}
use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class GeoNearOperationUnitTests method typedAggregationOperationContext.
private TypeBasedAggregationOperationContext typedAggregationOperationContext(Class<?> type) {
MongoMappingContext mappingContext = new MongoMappingContext();
MongoConverter converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext);
return new TypeBasedAggregationOperationContext(type, mappingContext, new QueryMapper(converter));
}
use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class RedactOperationUnitTests 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)).continueOnMissingFieldReference();
}
use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class UnionWithOperationUnitTests 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.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class AggregationUnitTests method projectOnIdIsAlwaysValid.
// DATAMONGO-2644
@Test
void projectOnIdIsAlwaysValid() {
MongoMappingContext mappingContext = new MongoMappingContext();
Document target = new Aggregation(bucket("start"), project("_id")).toDocument("collection-1", new RelaxedTypeBasedAggregationOperationContext(BookWithFieldAnnotation.class, mappingContext, new QueryMapper(new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext))));
assertThat(extractPipelineElement(target, 1, "$project")).isEqualTo(Document.parse(" { \"_id\" : \"$_id\" }"));
}
Aggregations