Search in sources :

Example 91 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext 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();
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper)

Example 92 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext 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));
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper)

Example 93 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.

the class MongoQueryCreatorUnitTests method beforeEach.

@BeforeEach
void beforeEach() {
    context = new MongoMappingContext();
    converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, context);
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 94 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.

the class StringBasedAggregationUnitTests method setUp.

@BeforeEach
void setUp() {
    converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
    when(operations.getConverter()).thenReturn(converter);
    when(operations.aggregate(any(TypedAggregation.class), any())).thenReturn(aggregationResults);
    when(operations.execute(any())).thenReturn(MongoClientSettings.getDefaultCodecRegistry());
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) TypedAggregation(org.springframework.data.mongodb.core.aggregation.TypedAggregation) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 95 with MongoMappingContext

use of org.springframework.data.mongodb.core.mapping.MongoMappingContext in project spring-data-mongodb by spring-projects.

the class ConvertingParameterAccessorUnitTests method setUp.

@BeforeEach
void setUp() {
    when(factory.getExceptionTranslator()).thenReturn(new MongoExceptionTranslator());
    this.context = new MongoMappingContext();
    this.resolver = new DefaultDbRefResolver(factory);
    this.converter = new MappingMongoConverter(resolver, context);
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) DefaultDbRefResolver(org.springframework.data.mongodb.core.convert.DefaultDbRefResolver) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) MongoExceptionTranslator(org.springframework.data.mongodb.core.MongoExceptionTranslator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)118 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)56 Test (org.junit.jupiter.api.Test)41 BeforeEach (org.junit.jupiter.api.BeforeEach)31 Document (org.bson.Document)19 QueryMapper (org.springframework.data.mongodb.core.convert.QueryMapper)19 DefaultDbRefResolver (org.springframework.data.mongodb.core.convert.DefaultDbRefResolver)13 MongoCustomConversions (org.springframework.data.mongodb.core.convert.MongoCustomConversions)10 Bson (org.bson.conversions.Bson)8 Before (org.junit.Before)8 Test (org.junit.Test)8 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)8 IndexOptions (com.mongodb.client.model.IndexOptions)7 CustomConversions (org.springframework.data.convert.CustomConversions)6 DbRefResolver (org.springframework.data.mongodb.core.convert.DbRefResolver)6 Document (org.springframework.data.mongodb.core.mapping.Document)6 Set (java.util.Set)5 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)5 CountOptions (com.mongodb.client.model.CountOptions)4 List (java.util.List)4