feature: add exec method on query & function
This commit is contained in:
@@ -41,11 +41,11 @@ class ConnectionTest(): TestAbstract() {
|
||||
) j;
|
||||
"""
|
||||
)
|
||||
assertTrue(objs !== null)
|
||||
assertNotNull(objs)
|
||||
assertTrue(objs is List<ObjTest2>)
|
||||
assertTrue(objs!!.size == 2)
|
||||
assertTrue(objs[0].id == 1)
|
||||
assertTrue(objs[0].test!!.id == 1)
|
||||
assertEquals(objs!!.size, 2)
|
||||
assertEquals(objs[0].id, 1)
|
||||
assertEquals(objs[0].test!!.id, 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package fr.postgresjson
|
||||
|
||||
import com.github.jasync.sql.db.QueryResult
|
||||
import com.github.jasync.sql.db.util.isCompleted
|
||||
import fr.postgresjson.connexion.Requester
|
||||
import fr.postgresjson.entity.IdEntity
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.File
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
class RequestTest: TestAbstract() {
|
||||
class ObjTest(var name:String): IdEntity(1)
|
||||
@@ -16,6 +20,7 @@ class RequestTest: TestAbstract() {
|
||||
.addQuery(resources)
|
||||
.getQuery("Test/selectOne")
|
||||
.selectOne()
|
||||
|
||||
assertEquals(objTest!!.id, 2)
|
||||
assertEquals(objTest.name, "test")
|
||||
}
|
||||
@@ -27,7 +32,32 @@ class RequestTest: TestAbstract() {
|
||||
.addFunction(resources)
|
||||
.getFunction("test_function")
|
||||
.selectOne(listOf("test", "plip"))
|
||||
|
||||
assertEquals(objTest!!.id, 3)
|
||||
assertEquals(objTest.name, "test")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callExecOnQuery() {
|
||||
val resources = File(this::class.java.getResource("/sql/query").toURI())
|
||||
val future: CompletableFuture<QueryResult> = Requester(getConnextion())
|
||||
.addQuery(resources)
|
||||
.getQuery("Test/selectOne")
|
||||
.exec()
|
||||
|
||||
future.join()
|
||||
Assertions.assertTrue(future.isCompleted)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callExecOnFunction() {
|
||||
val resources = File(this::class.java.getResource("/sql/function").toURI())
|
||||
val future: CompletableFuture<QueryResult> = Requester(getConnextion())
|
||||
.addFunction(resources)
|
||||
.getFunction("test_function")
|
||||
.exec(listOf("test", "plip"))
|
||||
|
||||
future.join()
|
||||
Assertions.assertTrue(future.isCompleted)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user