use of org.springframework.data.mongodb.gridfs.GridFsTemplate in project spring-boot by spring-projects.
the class MongoDataAutoConfigurationTests method whenGridFsDatabaseIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt.
@Test
void whenGridFsDatabaseIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.database:grid").run((context) -> {
assertThat(context).hasSingleBean(GridFsTemplate.class);
GridFsTemplate template = context.getBean(GridFsTemplate.class);
MongoDatabaseFactory factory = (MongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
assertThat(factory.getMongoDatabase().getName()).isEqualTo("grid");
});
}
use of org.springframework.data.mongodb.gridfs.GridFsTemplate in project spring-boot by spring-projects.
the class MongoDataAutoConfigurationTests method whenGridFsBucketIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt.
@Test
void whenGridFsBucketIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.bucket:test-bucket").run((context) -> {
assertThat(context).hasSingleBean(GridFsTemplate.class);
GridFsTemplate template = context.getBean(GridFsTemplate.class);
assertThat(template).hasFieldOrPropertyWithValue("bucket", "test-bucket");
});
}
Aggregations