Search in sources :

Example 1 with UpdateMapper

use of org.springframework.data.mongodb.core.convert.UpdateMapper in project spring-data-mongodb by spring-projects.

the class DefaultBulkOperationsIntegrationTests method createBulkOps.

private BulkOperations createBulkOps(BulkMode mode, Class<?> entityType) {
    Optional<? extends MongoPersistentEntity<?>> entity = entityType != null ? Optional.of(operations.getConverter().getMappingContext().getPersistentEntity(entityType)) : Optional.empty();
    BulkOperationContext bulkOperationContext = new BulkOperationContext(mode, entity, new QueryMapper(operations.getConverter()), new UpdateMapper(operations.getConverter()));
    DefaultBulkOperations bulkOps = new DefaultBulkOperations(operations, COLLECTION_NAME, bulkOperationContext);
    bulkOps.setDefaultWriteConcern(WriteConcern.ACKNOWLEDGED);
    return bulkOps;
}
Also used : BulkOperationContext(org.springframework.data.mongodb.core.DefaultBulkOperations.BulkOperationContext) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper) UpdateMapper(org.springframework.data.mongodb.core.convert.UpdateMapper)

Example 2 with UpdateMapper

use of org.springframework.data.mongodb.core.convert.UpdateMapper in project spring-data-mongodb by spring-projects.

the class DefaultBulkOperationsUnitTests method setUp.

@Before
public void setUp() {
    mappingContext = new MongoMappingContext();
    mappingContext.afterPropertiesSet();
    converter = new MappingMongoConverter(dbRefResolver, mappingContext);
    template = new MongoTemplate(factory, converter);
    when(factory.getDb()).thenReturn(database);
    when(database.getCollection(anyString(), eq(Document.class))).thenReturn(collection);
    ops = new DefaultBulkOperations(template, "collection-1", new BulkOperationContext(BulkMode.ORDERED, Optional.of(mappingContext.getPersistentEntity(SomeDomainType.class)), new QueryMapper(converter), new UpdateMapper(converter)));
}
Also used : BulkOperationContext(org.springframework.data.mongodb.core.DefaultBulkOperations.BulkOperationContext) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) Document(org.bson.Document) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper) UpdateMapper(org.springframework.data.mongodb.core.convert.UpdateMapper) Before(org.junit.Before)

Aggregations

BulkOperationContext (org.springframework.data.mongodb.core.DefaultBulkOperations.BulkOperationContext)2 QueryMapper (org.springframework.data.mongodb.core.convert.QueryMapper)2 UpdateMapper (org.springframework.data.mongodb.core.convert.UpdateMapper)2 Document (org.bson.Document)1 Before (org.junit.Before)1 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1