Search in sources :

Example 1 with ReactiveGridFsTemplate

use of org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate in project spring-boot by spring-projects.

the class MongoReactiveDataAutoConfigurationTests method whenGridFsBucketIsConfiguredThenGridFsTemplateUsesIt.

@Test
void whenGridFsBucketIsConfiguredThenGridFsTemplateUsesIt() {
    this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.bucket:test-bucket").run((context) -> {
        assertThat(context).hasSingleBean(ReactiveGridFsTemplate.class);
        ReactiveGridFsTemplate template = context.getBean(ReactiveGridFsTemplate.class);
        assertThat(template).hasFieldOrPropertyWithValue("bucket", "test-bucket");
    });
}
Also used : ReactiveGridFsTemplate(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate) Test(org.junit.jupiter.api.Test)

Example 2 with ReactiveGridFsTemplate

use of org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate in project spring-boot by spring-projects.

the class MongoReactiveDataAutoConfigurationTests method grisFsTemplateDatabaseName.

private String grisFsTemplateDatabaseName(AssertableApplicationContext context) {
    assertThat(context).hasSingleBean(ReactiveGridFsTemplate.class);
    ReactiveGridFsTemplate template = context.getBean(ReactiveGridFsTemplate.class);
    ReactiveMongoDatabaseFactory factory = (ReactiveMongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
    return factory.getMongoDatabase().block().getName();
}
Also used : ReactiveGridFsTemplate(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate) ReactiveMongoDatabaseFactory(org.springframework.data.mongodb.ReactiveMongoDatabaseFactory)

Aggregations

ReactiveGridFsTemplate (org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate)2 Test (org.junit.jupiter.api.Test)1 ReactiveMongoDatabaseFactory (org.springframework.data.mongodb.ReactiveMongoDatabaseFactory)1