use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class SpelExpressionTransformerIntegrationTests method setUp.
@Before
public void setUp() {
this.transformer = new SpelExpressionTransformer();
this.dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver 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);
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method setUp.
@BeforeEach
void setUp() {
doReturn("persons").when(persitentEntityMock).getCollection();
doReturn(persitentEntityMock).when(mappingContextMock).getPersistentEntity(Mockito.any(Class.class));
doReturn(persitentEntityMock).when(mappingContextMock).getRequiredPersistentEntity(Mockito.any(Class.class));
doReturn(Person.class).when(persitentEntityMock).getType();
MongoDatabaseFactory mongoDbFactory = mock(MongoDatabaseFactory.class);
when(mongoDbFactory.getExceptionTranslator()).thenReturn(new MongoExceptionTranslator());
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContextMock);
converter.afterPropertiesSet();
doReturn(converter).when(mongoOperationsMock).getConverter();
doReturn(executableFind).when(mongoOperationsMock).query(any());
doReturn(withQueryMock).when(executableFind).as(any());
doReturn(withQueryMock).when(withQueryMock).matching(any(Query.class));
doReturn(executableUpdate).when(mongoOperationsMock).update(any());
doReturn(updateWithQuery).when(executableUpdate).matching(any(Query.class));
doReturn(terminatingUpdate).when(updateWithQuery).apply(any(UpdateDefinition.class));
when(mongoOperationsMock.remove(any(), any(), anyString())).thenReturn(deleteResultMock);
when(mongoOperationsMock.updateMulti(any(), any(), any(), anyString())).thenReturn(updateResultMock);
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class PerformanceTests method setUp.
@BeforeEach
public void setUp() throws Exception {
this.mongo = MongoClients.create();
SimpleMongoClientDatabaseFactory mongoDbFactory = new SimpleMongoClientDatabaseFactory(this.mongo, DATABASE_NAME);
MongoMappingContext context = new MongoMappingContext();
context.setInitialEntitySet(Collections.singleton(Person.class));
context.afterPropertiesSet();
this.converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), context);
this.operations = new MongoTemplate(new SimpleMongoClientDatabaseFactory(this.mongo, DATABASE_NAME), converter);
MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId> factory = new MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId>(PersonRepository.class);
factory.setMongoOperations(operations);
factory.afterPropertiesSet();
this.repository = factory.getObject();
}
use of org.springframework.data.mongodb.core.convert.DefaultDbRefResolver in project spring-data-mongodb by spring-projects.
the class MongoTestTemplateConfiguration method mongoConverter.
MongoConverter mongoConverter() {
if (converter == null) {
converter = new MappingMongoConverter(new DefaultDbRefResolver(databaseFactory()), mappingContext());
if (mongoConverterConfigurer.customConversions != null) {
converter.setCustomConversions(mongoConverterConfigurer.customConversions);
}
converter.afterPropertiesSet();
}
return converter;
}
Aggregations