use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class SetOperationUnitTests 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 RelaxedTypeBasedAggregationOperationContext(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 ProjectionOperationUnitTests method nestedMappedFieldReferenceInArrayField.
// DATAMONGO-2312
@Test
void nestedMappedFieldReferenceInArrayField() {
MongoMappingContext mappingContext = new MongoMappingContext();
Document doc = //
project("author").andArrayOf(Fields.field("title"), "plain - string", ArithmeticOperators.valueOf("title").sum().and(10)).as(//
"myArray").toDocument(new TypeBasedAggregationOperationContext(BookWithFieldAnnotation.class, mappingContext, new QueryMapper(new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext))));
assertThat(doc).isEqualTo(Document.parse("{ $project: { \"author\" : 1, \"myArray\" : [ \"$ti_t_le\", \"plain - string\", { \"$sum\" : [\"$ti_t_le\", 10] } ] } } ] }"));
}
use of org.springframework.data.mongodb.core.convert.QueryMapper in project spring-data-mongodb by spring-projects.
the class MergeOperationUnitTests 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 TypeBasedAggregationOperationContextUnitTests method setUp.
@BeforeEach
public void setUp() {
this.context = new MongoMappingContext();
this.converter = new MappingMongoConverter(dbRefResolver, context);
this.mapper = new QueryMapper(converter);
}
Aggregations