clean Requester
This commit is contained in:
@@ -4,13 +4,13 @@ import fr.postgresjson.utils.searchSqlFiles
|
|||||||
import java.net.URI
|
import java.net.URI
|
||||||
import fr.postgresjson.definition.Function as DefinitionFunction
|
import fr.postgresjson.definition.Function as DefinitionFunction
|
||||||
|
|
||||||
fun DefinitionFunction.toConnection(connection: Connection): Function = Function(this, connection)
|
fun DefinitionFunction.toRunnable(connection: Connection): Function = Function(this, connection)
|
||||||
|
|
||||||
fun Sequence<DefinitionFunction>.toConnection(connection: Connection): Sequence<Function> = map { it.toConnection(connection) }
|
fun Sequence<DefinitionFunction>.toRunnable(connection: Connection): Sequence<Function> = map { it.toRunnable(connection) }
|
||||||
|
|
||||||
fun Sequence<Function>.toMutableMap(): MutableMap<String, Function> = map { it.name to it }.toMap().toMutableMap()
|
fun Sequence<Function>.toMutableMap(): MutableMap<String, Function> = map { it.name to it }.toMap().toMutableMap()
|
||||||
|
|
||||||
internal fun URI.toFunction(connection: Connection): MutableMap<String, Function> = searchSqlFiles()
|
internal fun URI.toFunction(connection: Connection): MutableMap<String, Function> = searchSqlFiles()
|
||||||
.filterIsInstance(DefinitionFunction::class.java)
|
.filterIsInstance(DefinitionFunction::class.java)
|
||||||
.toConnection(connection)
|
.toRunnable(connection)
|
||||||
.toMutableMap()
|
.toMutableMap()
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import fr.postgresjson.utils.searchSqlFiles
|
|||||||
import java.net.URI
|
import java.net.URI
|
||||||
import fr.postgresjson.definition.Query as QueryDefinition
|
import fr.postgresjson.definition.Query as QueryDefinition
|
||||||
|
|
||||||
fun QueryDefinition.toConnection(connection: Connection): Query = Query(name, script, connection)
|
fun QueryDefinition.toRunnable(connection: Connection): Query = Query(name, script, connection)
|
||||||
|
|
||||||
fun Sequence<QueryDefinition>.toConnection(connection: Connection): Sequence<Query> = map { it.toConnection(connection) }
|
fun Sequence<QueryDefinition>.toRunnable(connection: Connection): Sequence<Query> = map { it.toRunnable(connection) }
|
||||||
|
|
||||||
fun Sequence<Query>.toMutableMap(): MutableMap<String, Query> = map { it.name to it }.toMap().toMutableMap()
|
fun Sequence<Query>.toMutableMap(): MutableMap<String, Query> = map { it.name to it }.toMap().toMutableMap()
|
||||||
|
|
||||||
internal fun URI.toQuery(connection: Connection): MutableMap<String, Query> = searchSqlFiles()
|
internal fun URI.toQuery(connection: Connection): MutableMap<String, Query> = searchSqlFiles()
|
||||||
.filterIsInstance(QueryDefinition::class.java)
|
.filterIsInstance(QueryDefinition::class.java)
|
||||||
.toConnection(connection)
|
.toRunnable(connection)
|
||||||
.toMutableMap()
|
.toMutableMap()
|
||||||
|
|||||||
@@ -22,67 +22,46 @@ class Requester(
|
|||||||
functions = functionsDirectory?.toFunction(connection) ?: mutableMapOf(),
|
functions = functionsDirectory?.toFunction(connection) ?: mutableMapOf(),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun addQuery(query: Query): Requester {
|
fun addQuery(query: Query) {
|
||||||
queries[query.name] = query
|
queries[query.name] = query
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addQuery(query: QueryDefinition): Requester = addQuery(query.name, query.script)
|
fun addQuery(query: QueryDefinition) = addQuery(query.toRunnable(connection))
|
||||||
|
|
||||||
fun addQuery(name: String, sql: String): Requester {
|
fun addQuery(name: String, sql: String) {
|
||||||
addQuery(Query(name, sql, connection))
|
addQuery(Query(name, sql, connection))
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addQuery(queriesDirectory: URI): Requester {
|
fun addQuery(queriesDirectory: URI) {
|
||||||
queriesDirectory.searchSqlFiles()
|
queriesDirectory
|
||||||
.forEach {
|
.searchSqlFiles()
|
||||||
if (it is QueryDefinition) {
|
.filterIsInstance(QueryDefinition::class.java)
|
||||||
addQuery(it)
|
.forEach(this::addQuery)
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getQueries(): List<Query> {
|
fun getQueries(): List<Query> = queries.map { it.value }
|
||||||
return queries.map { it.value }
|
|
||||||
|
fun addFunction(definition: DefinitionFunction) {
|
||||||
|
definition
|
||||||
|
.run { toRunnable(connection) }
|
||||||
|
.run { functions[name] = this }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addFunction(definition: DefinitionFunction): Requester {
|
fun addFunction(sql: String) {
|
||||||
functions[definition.name] = Function(definition, connection)
|
DefinitionFunction(sql)
|
||||||
return this
|
.run { toRunnable(connection) }
|
||||||
|
.run { functions[name] = this }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addFunction(sql: String): Requester {
|
fun addFunctions(functionsDirectory: URI) {
|
||||||
DefinitionFunction(sql).let {
|
|
||||||
functions[it.name] = Function(it, connection)
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addFunction(functionsDirectory: URI): Requester {
|
|
||||||
functionsDirectory.searchSqlFiles()
|
functionsDirectory.searchSqlFiles()
|
||||||
.forEach {
|
.filterIsInstance(DefinitionFunction::class.java)
|
||||||
if (it is DefinitionFunction) {
|
.forEach(this::addFunction)
|
||||||
addFunction(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFunction(name: String): Function {
|
fun getFunction(name: String): Function = functions[name] ?: throw NoFunctionDefined(name)
|
||||||
if (functions[name] === null) {
|
|
||||||
throw NoFunctionDefined(name)
|
|
||||||
}
|
|
||||||
return functions[name]!!
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getQuery(path: String): Query {
|
fun getQuery(path: String): Query = queries[path] ?: throw NoQueryDefined(path)
|
||||||
if (queries[path] === null) {
|
|
||||||
throw NoQueryDefined(path)
|
|
||||||
}
|
|
||||||
return queries[path]!!
|
|
||||||
}
|
|
||||||
|
|
||||||
class NoFunctionDefined(name: String) : Exception("No function defined for $name")
|
class NoFunctionDefined(name: String) : Exception("No function defined for $name")
|
||||||
class NoQueryDefined(path: String) : Exception("No query defined in $path")
|
class NoQueryDefined(path: String) : Exception("No query defined in $path")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.nio.file.Path
|
|||||||
|
|
||||||
class Function(
|
class Function(
|
||||||
override val script: String,
|
override val script: String,
|
||||||
override var source: Path? = null
|
override val source: Path? = null
|
||||||
) : Resource, ParametersInterface {
|
) : Resource, ParametersInterface {
|
||||||
val returns: String
|
val returns: String
|
||||||
override val name: String
|
override val name: String
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ import java.nio.file.Path
|
|||||||
|
|
||||||
class Migration(
|
class Migration(
|
||||||
override val script: String,
|
override val script: String,
|
||||||
source: Path
|
override var source: Path
|
||||||
) : Resource {
|
) : Resource {
|
||||||
override val name: String
|
override val name: String
|
||||||
val direction: Direction
|
val direction: Direction
|
||||||
override var source: Path? = null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.source = source
|
|
||||||
this.direction = source.fileName.toString()
|
this.direction = source.fileName.toString()
|
||||||
.let {
|
.let {
|
||||||
when {
|
when {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import java.nio.file.Path
|
|||||||
|
|
||||||
class Query(
|
class Query(
|
||||||
override val script: String,
|
override val script: String,
|
||||||
source: Path
|
override var source: Path
|
||||||
) : Resource {
|
) : Resource {
|
||||||
override var source: Path? = source
|
|
||||||
override val name: String = getNameFromComment(script) ?: getNameFromFile(source)
|
override val name: String = getNameFromComment(script) ?: getNameFromFile(source)
|
||||||
|
|
||||||
/** Try to get name from comment in file */
|
/** Try to get name from comment in file */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.nio.file.Path
|
|||||||
sealed interface Resource {
|
sealed interface Resource {
|
||||||
val name: String
|
val name: String
|
||||||
val script: String
|
val script: String
|
||||||
var source: Path?
|
val source: Path?
|
||||||
|
|
||||||
open class ParseException(message: String, cause: Throwable? = null) : Exception(message, cause)
|
open class ParseException(message: String, cause: Throwable? = null) : Exception(message, cause)
|
||||||
|
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ class MigrationTest() : TestAbstract() {
|
|||||||
run().size `should be equal to` 5
|
run().size `should be equal to` 5
|
||||||
}
|
}
|
||||||
|
|
||||||
val objTest: RequesterTest.ObjTest? = Requester(connection)
|
val objTest: RequesterTest.ObjTest? = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.selectOne(listOf("test", "plip"))
|
.selectOne(listOf("test", "plip"))
|
||||||
|
|
||||||
@@ -115,8 +114,7 @@ class MigrationTest() : TestAbstract() {
|
|||||||
run().size `should be equal to` 1
|
run().size `should be equal to` 1
|
||||||
}
|
}
|
||||||
|
|
||||||
val objTest: RequesterTest.ObjTest? = Requester(connection)
|
val objTest: RequesterTest.ObjTest? = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function_duplicate")
|
.getFunction("test_function_duplicate")
|
||||||
.selectOne(listOf("test"))
|
.selectOne(listOf("test"))
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ class RequesterTest : TestAbstract() {
|
|||||||
class ObjTest(val name: String, id: UUID = UUID.fromString("5623d902-3067-42f3-bfd9-095dbb12c29f")) : UuidEntity(id)
|
class ObjTest(val name: String, id: UUID = UUID.fromString("5623d902-3067-42f3-bfd9-095dbb12c29f")) : UuidEntity(id)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `function toString`() {
|
fun `requester constructor empty`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val name: String = Requester(connection)
|
val name: String = Requester(connection)
|
||||||
.addFunction(resources)
|
.apply { addFunctions(resources) }
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.name
|
.name
|
||||||
|
|
||||||
@@ -58,18 +58,29 @@ class RequesterTest : TestAbstract() {
|
|||||||
$$
|
$$
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
val name: String = Requester(connection)
|
val name: String = Requester(connection)
|
||||||
.addFunction(sql)
|
.apply { addFunction(sql) }
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.name
|
.name
|
||||||
|
|
||||||
assertEquals("test_function", name)
|
assertEquals("test_function", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `add query from string`() {
|
||||||
|
val result: Int = Requester(connection)
|
||||||
|
.apply { addQuery("simpleTest", "select 42;") }
|
||||||
|
.getQuery("simpleTest")
|
||||||
|
.exec()
|
||||||
|
.rows[0].getInt(0)!!
|
||||||
|
|
||||||
|
assertEquals(result, 42)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get query from file`() {
|
fun `get query from file`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val objTest: ObjTest? = Requester(connection)
|
val objTest: ObjTest? = Requester(connection)
|
||||||
.addQuery(resources)
|
.apply { addQuery(resources) }
|
||||||
.getQuery("selectOne")
|
.getQuery("selectOne")
|
||||||
.selectOne()
|
.selectOne()
|
||||||
|
|
||||||
@@ -81,8 +92,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
fun `get query from file with wrong name throw exception`() {
|
fun `get query from file with wrong name throw exception`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
assertThrows(NoQueryDefined::class.java) {
|
assertThrows(NoQueryDefined::class.java) {
|
||||||
Requester(connection)
|
Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("wrongName")
|
.getQuery("wrongName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +100,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `get queries from file`() {
|
fun `get queries from file`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val name: String = Requester(connection)
|
val name: String = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQueries()[0].name
|
.getQueries()[0].name
|
||||||
|
|
||||||
assertEquals(name, "DeleteTest")
|
assertEquals(name, "DeleteTest")
|
||||||
@@ -101,8 +110,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
fun `get function from file with wrong name throw exception`() {
|
fun `get function from file with wrong name throw exception`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
assertThrows(NoFunctionDefined::class.java) {
|
assertThrows(NoFunctionDefined::class.java) {
|
||||||
Requester(connection)
|
Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("wrongName")
|
.getFunction("wrongName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,8 +118,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `get function from file`() {
|
fun `get function from file`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val objTest: ObjTest? = Requester(connection)
|
val objTest: ObjTest? = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.selectOne(listOf("test", "plip"))
|
.selectOne(listOf("test", "plip"))
|
||||||
|
|
||||||
@@ -122,8 +129,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call exec on query`() {
|
fun `call exec on query`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val result = Requester(connection)
|
val result = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("selectOne")
|
.getQuery("selectOne")
|
||||||
.exec()
|
.exec()
|
||||||
|
|
||||||
@@ -133,8 +139,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call exec on function`() {
|
fun `call exec on function`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val result = Requester(connection)
|
val result = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.exec(listOf("test", "plip"))
|
.exec(listOf("test", "plip"))
|
||||||
|
|
||||||
@@ -144,8 +149,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call sendQuery on query with name`() {
|
fun `call sendQuery on query with name`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val result = Requester(connection)
|
val result = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("DeleteTest")
|
.getQuery("DeleteTest")
|
||||||
.sendQuery()
|
.sendQuery()
|
||||||
|
|
||||||
@@ -155,8 +159,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call sendQuery on function`() {
|
fun `call sendQuery on function`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val result = Requester(connection)
|
val result = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("function_void")
|
.getFunction("function_void")
|
||||||
.sendQuery(listOf("test"))
|
.sendQuery(listOf("test"))
|
||||||
|
|
||||||
@@ -166,8 +169,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call selectOne on function`() {
|
fun `call selectOne on function`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.selectOne(mapOf("name" to "myName"))!!
|
.selectOne(mapOf("name" to "myName"))!!
|
||||||
|
|
||||||
@@ -178,8 +180,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
fun `call selectOne on function with object and named argument`() {
|
fun `call selectOne on function with object and named argument`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val obj2 = ObjTest("original")
|
val obj2 = ObjTest("original")
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function_object")
|
.getFunction("test_function_object")
|
||||||
.selectOne("resource" to obj2)!!
|
.selectOne("resource" to obj2)!!
|
||||||
|
|
||||||
@@ -191,8 +192,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
fun `call selectOne on function with object`() {
|
fun `call selectOne on function with object`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val obj2 = ObjTest("original")
|
val obj2 = ObjTest("original")
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function_object")
|
.getFunction("test_function_object")
|
||||||
.selectOne(obj2)!!
|
.selectOne(obj2)!!
|
||||||
|
|
||||||
@@ -203,8 +203,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call selectOne on function with object and no arguments`() {
|
fun `call selectOne on function with object and no arguments`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function")
|
.getFunction("test_function")
|
||||||
.selectOne()!!
|
.selectOne()!!
|
||||||
|
|
||||||
@@ -214,8 +213,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call selectOne on query`() {
|
fun `call selectOne on query`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("selectOneWithParameters")
|
.getQuery("selectOneWithParameters")
|
||||||
.selectOne(mapOf("name" to "myName"))!!
|
.selectOne(mapOf("name" to "myName"))!!
|
||||||
|
|
||||||
@@ -225,8 +223,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call select (multiple) on function`() {
|
fun `call select (multiple) on function`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||||
val obj: List<ObjTest>? = Requester(connection)
|
val obj: List<ObjTest>? = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function_multiple")
|
.getFunction("test_function_multiple")
|
||||||
.select(mapOf("name" to "myName"))
|
.select(mapOf("name" to "myName"))
|
||||||
|
|
||||||
@@ -236,8 +233,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call select paginated on query`() {
|
fun `call select paginated on query`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val result: Paginated<ObjTest> = Requester(connection)
|
val result: Paginated<ObjTest> = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("selectPaginated")
|
.getQuery("selectPaginated")
|
||||||
.select(1, 2, mapOf("name" to "ff"))
|
.select(1, 2, mapOf("name" to "ff"))
|
||||||
Assert.assertNotNull(result)
|
Assert.assertNotNull(result)
|
||||||
@@ -250,8 +246,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call select paginated on function`() {
|
fun `call select paginated on function`() {
|
||||||
val resources = this::class.java.getResource("/sql/function").toURI()
|
val resources = this::class.java.getResource("/sql/function").toURI()
|
||||||
val result: Paginated<ObjTest> = Requester(connection)
|
val result: Paginated<ObjTest> = Requester(connection, functionsDirectory = resources)
|
||||||
.addFunction(resources)
|
|
||||||
.getFunction("test_function_paginated")
|
.getFunction("test_function_paginated")
|
||||||
.select(1, 2, mapOf("name" to "ff"))
|
.select(1, 2, mapOf("name" to "ff"))
|
||||||
Assert.assertNotNull(result)
|
Assert.assertNotNull(result)
|
||||||
@@ -264,8 +259,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
@Test
|
@Test
|
||||||
fun `call selectOne on query with extra parameter`() {
|
fun `call selectOne on query with extra parameter`() {
|
||||||
val resources = this::class.java.getResource("/sql/query").toURI()
|
val resources = this::class.java.getResource("/sql/query").toURI()
|
||||||
val obj: ObjTest = Requester(connection)
|
val obj: ObjTest = Requester(connection, queriesDirectory = resources)
|
||||||
.addQuery(resources)
|
|
||||||
.getQuery("selectOneWithParameters")
|
.getQuery("selectOneWithParameters")
|
||||||
.selectOne(mapOf("name" to "myName")) {
|
.selectOne(mapOf("name" to "myName")) {
|
||||||
assertEquals("myName", it!!.name)
|
assertEquals("myName", it!!.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user