Search in sources :

Example 1 with SimpleReactiveMongoDatabaseFactory

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

the class ReactiveAggregationUnitTests method setUp.

@Before
public void setUp() {
    factory = new SimpleReactiveMongoDatabaseFactory(mongoClient, "db");
    template = new ReactiveMongoTemplate(factory);
    when(mongoClient.getDatabase("db")).thenReturn(db);
    when(db.getCollection(eq(INPUT_COLLECTION), any(Class.class))).thenReturn(collection);
    when(collection.aggregate(anyList(), any(Class.class))).thenReturn(publisher);
    when(publisher.allowDiskUse(any())).thenReturn(publisher);
    when(publisher.useCursor(any())).thenReturn(publisher);
    when(publisher.collation(any())).thenReturn(publisher);
}
Also used : SimpleReactiveMongoDatabaseFactory(org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory) ReactiveMongoTemplate(org.springframework.data.mongodb.core.ReactiveMongoTemplate) Before(org.junit.Before)

Example 2 with SimpleReactiveMongoDatabaseFactory

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

the class ReactivePerformanceTests method setUp.

@Before
public void setUp() throws Exception {
    mongo = MongoClients.create();
    SimpleReactiveMongoDatabaseFactory mongoDbFactory = new SimpleReactiveMongoDatabaseFactory(this.mongo, DATABASE_NAME);
    MongoMappingContext context = new MongoMappingContext();
    context.setInitialEntitySet(Collections.singleton(Person.class));
    context.afterPropertiesSet();
    converter = new MappingMongoConverter(new DbRefResolver() {

        @Override
        public Object resolveDbRef(MongoPersistentProperty property, DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler proxyHandler) {
            return null;
        }

        @Override
        public DBRef createDbRef(org.springframework.data.mongodb.core.mapping.DBRef annotation, MongoPersistentEntity<?> entity, Object id) {
            return null;
        }

        @Override
        public Document fetch(DBRef dbRef) {
            return null;
        }

        @Override
        public List<Document> bulkFetch(List<DBRef> dbRefs) {
            return null;
        }
    }, context);
    operations = new ReactiveMongoTemplate(mongoDbFactory, converter);
    ReactiveMongoRepositoryFactory factory = new ReactiveMongoRepositoryFactory(operations);
    repository = factory.getRepository(ReactivePersonRepository.class);
}
Also used : MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) DbRefResolverCallback(org.springframework.data.mongodb.core.convert.DbRefResolverCallback) DBRef(com.mongodb.DBRef) DbRefResolver(org.springframework.data.mongodb.core.convert.DbRefResolver) Document(org.bson.Document) SimpleReactiveMongoDatabaseFactory(org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory) ReactiveMongoTemplate(org.springframework.data.mongodb.core.ReactiveMongoTemplate) MongoPersistentEntity(org.springframework.data.mongodb.core.mapping.MongoPersistentEntity) ReactiveMongoRepositoryFactory(org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) BasicDBObject(com.mongodb.BasicDBObject) BasicDBList(com.mongodb.BasicDBList) DbRefProxyHandler(org.springframework.data.mongodb.core.convert.DbRefProxyHandler) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 ReactiveMongoTemplate (org.springframework.data.mongodb.core.ReactiveMongoTemplate)2 SimpleReactiveMongoDatabaseFactory (org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory)2 BasicDBList (com.mongodb.BasicDBList)1 BasicDBObject (com.mongodb.BasicDBObject)1 DBRef (com.mongodb.DBRef)1 Document (org.bson.Document)1 DbRefProxyHandler (org.springframework.data.mongodb.core.convert.DbRefProxyHandler)1 DbRefResolver (org.springframework.data.mongodb.core.convert.DbRefResolver)1 DbRefResolverCallback (org.springframework.data.mongodb.core.convert.DbRefResolverCallback)1 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1 MongoPersistentEntity (org.springframework.data.mongodb.core.mapping.MongoPersistentEntity)1 MongoPersistentProperty (org.springframework.data.mongodb.core.mapping.MongoPersistentProperty)1 ReactiveMongoRepositoryFactory (org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory)1