Skip to content

Commit 0f29fa0

Browse files
committed
1 parent c26b4c9 commit 0f29fa0

File tree

5 files changed

+26
-104
lines changed

5 files changed

+26
-104
lines changed

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/impl/DbUri.kt

+1-10
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,10 @@ import java.util.LinkedHashMap
3636
class DbUri : Uri {
3737

3838
private val type: String
39-
private val action: String
4039
private val objects: List<String>
4140
private val recursive: Boolean?
4241
private val params = LinkedHashMap<String, String>()
43-
44-
/*
45-
constructor(type: String, vararg objects: String) {
46-
this.type = type
47-
this.objects = Arrays.asList(*objects)
48-
this.action = ""
49-
this.recursive = false
50-
}
51-
*/
42+
private val action: String
5243

5344
constructor(type: String, objects: List<String>) {
5445
this.type = type

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/wrappers/HttpParserWrapper.kt

-57
This file was deleted.

src/test/kotlin/com/github/mgramin/sqlboot/uri/DbUriTest.kt src/test/kotlin/com/github/mgramin/sqlboot/model/uri/DbUriTest.kt

+1-14
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
* SOFTWARE.
2323
*/
2424

25-
package com.github.mgramin.sqlboot.uri
25+
package com.github.mgramin.sqlboot.model.uri
2626

27-
import com.github.mgramin.sqlboot.exceptions.BootException
2827
import com.github.mgramin.sqlboot.model.uri.impl.DbUri
2928
import com.github.mgramin.sqlboot.model.uri.wrappers.JsonWrapper
3029
import org.junit.Assert.assertEquals
3130
import org.junit.Test
32-
import java.net.URISyntaxException
3331

3432
/**
3533
* Created by maksim on 12.06.16.
@@ -48,68 +46,58 @@ class DbUriTest {
4846
}
4947

5048
@Test
51-
@Throws(BootException::class)
5249
fun createAllTableWithChildObjectsFromSchema() {
5350
test("table/hr.*/", "DbUri{type='table', path=[hr, *], recursive=true, params={}}")
5451
}
5552

5653
@Test
57-
@Throws(BootException::class)
5854
fun dropAllTableFromSchema() {
5955
test("table/hr.*/drop", "DbUri{type='table', path=[hr, *], recursive=false, params={}}")
6056
}
6157

6258
@Test
63-
@Throws(BootException::class)
6459
fun createColumnsForTable() {
6560
test("column/hr.persons.*name",
6661
"DbUri{type='column', path=[hr, persons, *name], recursive=false, params={}}")
6762
}
6863

6964
@Test
70-
@Throws(BootException::class)
7165
fun dropColumnFromTable() {
7266
test("column/hr.persons.name/drop",
7367
"DbUri{type='column', path=[hr, persons, name], recursive=false, params={}}")
7468
}
7569

7670
@Test
77-
@Throws(BootException::class)
7871
fun createAllFkForTable() {
7972
test("fk/hr.employees.*",
8073
"DbUri{type='fk', path=[hr, employees, *], recursive=false, params={}}")
8174
}
8275

8376
@Test
84-
@Throws(BootException::class)
8577
fun dropAllFkFromTable() {
8678
test("fk/hr.employees.*/drop",
8779
"DbUri{type='fk', path=[hr, employees, *], recursive=false, params={}}")
8880
}
8981

9082
@Test
91-
@Throws(BootException::class)
9283
fun disableAllFkFromTable() {
9384
test("fk/hr.employees.*/disable",
9485
"DbUri{type='fk', path=[hr, employees, *], recursive=false, params={}}")
9586
}
9687

9788
@Test
98-
@Throws(BootException::class)
9989
fun disableAllFkFromSchema() {
10090
test("fk/hr.*.*/disable",
10191
"DbUri{type='fk', path=[hr, *, *], recursive=false, params={}}")
10292
}
10393

10494
@Test
105-
@Throws(BootException::class)
10695
fun testDefaultActionIsCreate() {
10796
test("fk/hr.*.*",
10897
"DbUri{type='fk', path=[hr, *, *], recursive=false, params={}}")
10998
}
11099

111100
@Test
112-
@Throws(BootException::class, URISyntaxException::class)
113101
fun testParams() {
114102
test("t/hr?@table_comment=big_table",
115103
"DbUri{type='t', path=[hr], recursive=false, params={@table_comment=big_table}}")
@@ -123,7 +111,6 @@ class DbUriTest {
123111
assertEquals("count", dbUri.action())
124112
}
125113

126-
@Throws(BootException::class)
127114
private fun test(uriString: String, jsonExpected: String) {
128115
val uri = DbUri(uriString)
129116
assertEquals(uriString, uri.toString())

src/test/kotlin/com/github/mgramin/sqlboot/model/uri/wrappers/JsonWrapperTest.kt

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,42 @@ package com.github.mgramin.sqlboot.model.uri.wrappers
2626

2727
import com.github.mgramin.sqlboot.model.uri.Uri
2828
import com.github.mgramin.sqlboot.model.uri.impl.DbUri
29-
import org.junit.Assert.assertEquals
30-
import org.junit.Assert.assertTrue
31-
import org.junit.Test
29+
import org.junit.jupiter.api.Assertions.assertEquals
30+
import org.junit.jupiter.api.Assertions.assertTrue
31+
import org.junit.jupiter.api.Test
3232

3333
class JsonWrapperTest {
3434

35-
internal val uri: Uri = JsonWrapper(DbUri("table/hr.*persons*/"))
35+
private val uri: Uri = JsonWrapper(DbUri("table/hr.*persons*/?select=name,age"))
3636

3737
@Test
38-
@Throws(Exception::class)
3938
fun type() {
4039
assertEquals("table", uri.type())
4140
}
4241

4342
@Test
44-
@Throws(Exception::class)
4543
fun path() {
46-
assertEquals("%persons%", uri.path()[1])
44+
assertEquals(arrayListOf("hr", "%persons%"), uri.path())
45+
}
46+
47+
@Test
48+
fun pathIndex() {
49+
assertEquals("%persons%", uri.path(1))
4750
}
4851

4952
@Test
50-
@Throws(Exception::class)
5153
fun recursive() {
5254
assertTrue(uri.recursive()!!)
5355
}
5456

5557
@Test
56-
@Throws(Exception::class)
5758
fun params() {
58-
assertEquals(0, uri.params().size.toLong())
59+
assertEquals(1, uri.params().size)
5960
}
6061

6162
@Test
62-
@Throws(Exception::class)
6363
fun toStringTest() {
64-
assertEquals("DbUri{type='table', path=[hr, *persons*], recursive=true, params={}}",
64+
assertEquals("DbUri{type='table', path=[hr, *persons*], recursive=true, params={select=name,age}}",
6565
uri.toString())
6666
}
6767
}

src/test/kotlin/com/github/mgramin/sqlboot/model/uri/wrappers/SqlPlaceholdersWrapperTest.kt

+12-11
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,37 @@ package com.github.mgramin.sqlboot.model.uri.wrappers
2626

2727
import com.github.mgramin.sqlboot.model.uri.Uri
2828
import com.github.mgramin.sqlboot.model.uri.impl.DbUri
29-
import org.junit.Assert.assertEquals
30-
import org.junit.Assert.assertTrue
31-
import org.junit.Test
29+
import org.junit.Assert
30+
import org.junit.jupiter.api.Assertions.assertEquals
31+
import org.junit.jupiter.api.Assertions.assertTrue
32+
import org.junit.jupiter.api.Test
3233

3334
class SqlPlaceholdersWrapperTest {
3435

35-
internal val uri: Uri = SqlPlaceholdersWrapper(DbUri("table/hr.*persons*/"))
36+
private val uri: Uri = SqlPlaceholdersWrapper(DbUri("table/hr.*persons*/?select=name,age"))
3637

3738
@Test
38-
@Throws(Exception::class)
3939
fun type() {
4040
assertEquals("table", uri.type())
4141
}
4242

4343
@Test
44-
@Throws(Exception::class)
4544
fun path() {
46-
assertEquals("hr", uri.path()[0])
47-
assertEquals("%persons%", uri.path()[1])
45+
assertEquals(arrayListOf("hr", "%persons%"), uri.path())
46+
}
47+
48+
@Test
49+
fun pathIndex() {
50+
Assert.assertEquals("%persons%", uri.path(1))
4851
}
4952

5053
@Test
51-
@Throws(Exception::class)
5254
fun recursive() {
5355
assertTrue(uri.recursive()!!)
5456
}
5557

5658
@Test
57-
@Throws(Exception::class)
5859
fun params() {
59-
assertEquals(0, uri.params().size.toLong())
60+
assertEquals(1, uri.params().size)
6061
}
6162
}

0 commit comments

Comments
 (0)