Skip to content

Commit ac99d52

Browse files
committed
1 parent a865987 commit ac99d52

File tree

5 files changed

+39
-53
lines changed

5 files changed

+39
-53
lines changed

src/main/kotlin/com/github/mgramin/sqlboot/model/connection/SimpleEndpoint.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
package com.github.mgramin.sqlboot.model.connection
3434

3535
import com.fasterxml.jackson.annotation.JsonIgnore
36-
import com.google.gson.Gson
37-
import com.google.gson.reflect.TypeToken
3836
import org.apache.tomcat.jdbc.pool.DataSource
3937

4038
/**
@@ -45,18 +43,14 @@ import org.apache.tomcat.jdbc.pool.DataSource
4543
open class SimpleEndpoint(
4644
var name: String? = null,
4745
var host: String? = null,
48-
var properties: String? = null
46+
var properties: Map<String, Any>? = null
4947
) : Endpoint {
5048

5149
override fun name() = name!!
5250

5351
override fun host() = host!!
5452

55-
override fun properties(): Map<String, Any> =
56-
Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)
57-
58-
fun getProperties(): Map<String, Any> =
59-
Gson().fromJson(properties, object : TypeToken<Map<String, Any>>() {}.type)
53+
override fun properties(): Map<String, Any> = properties!!
6054

6155
private var dataSource: DataSource? = null
6256

src/main/resources/application.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@ conf:
1414
endpoints:
1515
- name: h2
1616
host: 127.0.0.1
17-
properties: >
18-
{
19-
"sql.dialect": "h2",
20-
"fs.base.folder": "conf/h2/md/database",
21-
"jdbc.url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
22-
"jdbc.driver.class.name": "org.h2.Driver",
23-
"jdbc.user": "",
24-
"jdbc.password": "",
25-
"os.query.rest.port": "8082",
26-
"visible": true,
27-
"description": "Embedded db for unit tests only"
28-
}
17+
properties:
18+
sql.dialect: h2
19+
fs.base.folder: conf/h2/md/database
20+
jdbc.url: jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';
21+
jdbc.driver.class.name: org.h2.Driver
22+
jdbc.user:
23+
jdbc.password:
24+
os.query.rest.port: 8082
25+
visible: true
26+
description: Embedded db for unit tests only
2927

3028
server:
3129
port: 8007

src/test/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/FsResourceTypeTest.kt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ class FsResourceTypeTest {
6161
init {
6262
dbMd.name = "unit_test_db_md"
6363
dbMd.host = "127.0.0.1"
64-
dbMd.properties = """
65-
{
66-
"fs_base_folder": "conf/h2/md/database",
67-
"sql_dialect": "h2",
68-
"jdbc_url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
69-
"jdbc_driver_class_name": "org.h2.Driver"
70-
}
71-
""".trimIndent()
64+
dbMd.properties = mapOf(
65+
"fs_base_folder" to "conf/h2/md/database",
66+
"sql_dialect" to "h2",
67+
"jdbc_url" to "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
68+
"jdbc_driver_class_name" to "org.h2.Driver"
69+
)
7270
}
7371

7472
@ParameterizedTest
@@ -80,12 +78,12 @@ class FsResourceTypeTest {
8078
"prod/table/bookings,5",
8179
"prod/table/bookings.airports,1")
8280
fun read(uri: String, count: Long) {
83-
connections.forEach {
84-
StepVerifier
85-
.create(FsResourceType(listOf(it), listOf(FakeDialect())).read(DbUri(uri)))
86-
.expectNextCount(count)
87-
.verifyComplete()
88-
}
81+
connections.forEach {
82+
StepVerifier
83+
.create(FsResourceType(listOf(it), listOf(FakeDialect())).read(DbUri(uri)))
84+
.expectNextCount(count)
85+
.verifyComplete()
86+
}
8987
}
9088

9189
@Test

src/test/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/SqlResourceTypeTest.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ class SqlResourceTypeTest {
5959
init {
6060
db.name = "unit_test_db"
6161
db.host = "127.0.0.1"
62-
db.properties = """
63-
{
64-
"sql_dialect": "h2",
65-
"jdbc_url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
66-
"jdbc_driver_class_name": "org.h2.Driver"
67-
}
68-
""".trimIndent()
62+
db.properties = mapOf(
63+
"sql_dialect" to "h2",
64+
"jdbc_url" to "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
65+
"jdbc_driver_class_name" to "org.h2.Driver"
66+
)
6967
}
7068

7169
@Test

src/test/resources/application.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ conf:
88
endpoints:
99
- name: h2
1010
host: 127.0.0.1
11-
properties: >
12-
{
13-
"sql_dialect": "h2",
14-
"fs_base_folder": "conf/h2/md/database",
15-
"jdbc_url": "jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';",
16-
"jdbc_driver_class_name": "org.h2.Driver",
17-
"jdbc.user": "",
18-
"jdbc.password": "",
19-
"os.query.rest.port": "8082",
20-
"visible": false,
21-
"description": "Embedded db for unit tests only"
22-
}
11+
properties:
12+
sql_dialect: h2
13+
fs_base_folder: conf/h2/md/database
14+
jdbc_url: jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'classpath:schema.sql';
15+
jdbc_driver_class_name: org.h2.Driver
16+
jdbc.user:
17+
jdbc.password:
18+
os.query.rest.port: 8082
19+
visible: false
20+
description: Embedded db for unit tests only
2321

2422
spring:
2523
jmx:

0 commit comments

Comments
 (0)