Search in sources :

Example 1 with ReactiveMongoRepositoryFactory

use of org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory in project spring-data-mongodb by spring-projects.

the class ReactiveMongoRepositoryTests method setUp.

@Before
public void setUp() throws Exception {
    factory = new ReactiveMongoRepositoryFactory(template);
    factory.setRepositoryBaseClass(SimpleReactiveMongoRepository.class);
    factory.setBeanClassLoader(classLoader);
    factory.setBeanFactory(beanFactory);
    factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE);
    repository = factory.getRepository(ReactivePersonRepository.class);
    cappedRepository = factory.getRepository(ReactiveCappedCollectionRepository.class);
    StepVerifier.create(repository.deleteAll()).verifyComplete();
    dave = new Person("Dave", "Matthews", 42);
    oliver = new Person("Oliver August", "Matthews", 4);
    carter = new Person("Carter", "Beauford", 49);
    carter.setSkills(Arrays.asList("Drums", "percussion", "vocals"));
    Thread.sleep(10);
    boyd = new Person("Boyd", "Tinsley", 45);
    boyd.setSkills(Arrays.asList("Violin", "Electric Violin", "Viola", "Mandolin", "Vocals", "Guitar"));
    stefan = new Person("Stefan", "Lessard", 34);
    leroi = new Person("Leroi", "Moore", 41);
    alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE);
    // 
    StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia))).expectNextCount(// 
    7).verifyComplete();
}
Also used : ReactiveMongoRepositoryFactory(org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory) Before(org.junit.Before)

Example 2 with ReactiveMongoRepositoryFactory

use of org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory in project spring-data-mongodb by spring-projects.

the class SimpleReactiveMongoRepositoryTests method setUp.

@BeforeEach
void setUp() {
    factory = new ReactiveMongoRepositoryFactory(template);
    factory.setRepositoryBaseClass(SimpleReactiveMongoRepository.class);
    factory.setBeanClassLoader(classLoader);
    factory.setBeanFactory(beanFactory);
    factory.setEvaluationContextProvider(ReactiveQueryMethodEvaluationContextProvider.DEFAULT);
    repository = factory.getRepository(ReactivePersonRepository.class);
    immutableRepository = factory.getRepository(ReactiveImmutablePersonRepository.class);
    repository.deleteAll().as(StepVerifier::create).verifyComplete();
    immutableRepository.deleteAll().as(StepVerifier::create).verifyComplete();
    dave = new ReactivePerson("Dave", "Matthews", 42);
    oliver = new ReactivePerson("Oliver August", "Matthews", 4);
    carter = new ReactivePerson("Carter", "Beauford", 49);
    boyd = new ReactivePerson("Boyd", "Tinsley", 45);
    stefan = new ReactivePerson("Stefan", "Lessard", 34);
    leroi = new ReactivePerson("Leroi", "Moore", 41);
    alicia = new ReactivePerson("Alicia", "Keys", 30);
    keith = new ImmutableReactivePerson(null, "Keith", "Urban", 53);
    james = new ImmutableReactivePerson(null, "James", "Arthur", 33);
    mariah = new ImmutableReactivePerson(null, "Mariah", "Carey", 51);
    // 
    repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia)).as(StepVerifier::create).expectNextCount(// 
    7).verifyComplete();
}
Also used : ReactiveMongoRepositoryFactory(org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory) StepVerifier(reactor.test.StepVerifier) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ReactiveMongoRepositoryFactory

use of org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory in project spring-data-mongodb by spring-projects.

the class ReactivePerformanceTests method setUp.

@BeforeEach
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() {

        @Nullable
        @Override
        public Object resolveReference(MongoPersistentProperty property, Object source, ReferenceLookupDelegate referenceLookupDelegate, MongoEntityReader entityReader) {
            return null;
        }

        @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) ReferenceLookupDelegate(org.springframework.data.mongodb.core.convert.ReferenceLookupDelegate) 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) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ReactiveMongoRepositoryFactory (org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 BasicDBList (com.mongodb.BasicDBList)1 BasicDBObject (com.mongodb.BasicDBObject)1 DBRef (com.mongodb.DBRef)1 Document (org.bson.Document)1 Before (org.junit.Before)1 ReactiveMongoTemplate (org.springframework.data.mongodb.core.ReactiveMongoTemplate)1 SimpleReactiveMongoDatabaseFactory (org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory)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 ReferenceLookupDelegate (org.springframework.data.mongodb.core.convert.ReferenceLookupDelegate)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 StepVerifier (reactor.test.StepVerifier)1