MongoDB Binding

This change expands the MongoDB bindings to handle more properties.

[resolves #6]

Signed-off-by: Ben Hale <bhale@vmware.com>
This commit is contained in:
Ben Hale
2020-05-11 15:45:57 -07:00
parent c864bbaaed
commit 0416df43f7
3 changed files with 29 additions and 1 deletions

View File

@@ -43,7 +43,14 @@ public final class MongoDbBindingsPropertiesProcessor implements BindingsPropert
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
map.from("authentication-database").to("spring.mongodb.authentication-database");
map.from("database").to("spring.mongodb.database");
map.from("grid-fs-database").to("spring.mongodb.grid-fs-database");
map.from("host").to("spring.mongodb.host");
map.from("password").to("spring.mongodb.password");
map.from("port").to("spring.mongodb.port");
map.from("uri").to("spring.mongodb.uri");
map.from("username").to("spring.mongodb.username");
});
}

View File

@@ -37,7 +37,14 @@ final class MongoDbBindingsPropertiesProcessorTest {
new Binding("test-name", Paths.get("test-path"),
Collections.singletonMap("kind", KIND),
new FluentMap()
.withEntry("authentication-database", "test-authentication-database")
.withEntry("database", "test-database")
.withEntry("grid-fs-database", "test-grid-fs-database")
.withEntry("host", "test-host")
.withEntry("password", "test-password")
.withEntry("port", "test-port")
.withEntry("uri", "test-uri")
.withEntry("username", "test-username")
)
);
@@ -50,7 +57,14 @@ final class MongoDbBindingsPropertiesProcessorTest {
void test() {
new MongoDbBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.mongodb.uri", "test-uri");
.containsEntry("spring.mongodb.authentication-database", "test-authentication-database")
.containsEntry("spring.mongodb.database", "test-database")
.containsEntry("spring.mongodb.grid-fs-database", "test-grid-fs-database")
.containsEntry("spring.mongodb.host", "test-host")
.containsEntry("spring.mongodb.password", "test-password")
.containsEntry("spring.mongodb.port", "test-port")
.containsEntry("spring.mongodb.uri", "test-uri")
.containsEntry("spring.mongodb.username", "test-username");
}
@Test