refactoring: move Query/Function logic into Requester class
This commit is contained in:
@@ -2,39 +2,23 @@ package fr.postgresjson
|
||||
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.entity.IdEntity
|
||||
import org.junit.jupiter.api.*
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import java.io.File
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ConnectionTest() {
|
||||
class ConnectionTest(): TestAbstract() {
|
||||
private class ObjTest(var name: String): IdEntity()
|
||||
private class ObjTest2(var title: String, var test: ObjTest?): IdEntity()
|
||||
|
||||
private lateinit var connection: Connection
|
||||
|
||||
fun getConnextion(): Connection {
|
||||
return Connection(database = "test", username = "test", password = "test")
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
fun beforeAll() {
|
||||
val initSQL = File(this::class.java.getResource("/fixtures/init.sql").toURI())
|
||||
val promise = getConnextion().connect().sendQuery(initSQL.readText())
|
||||
promise.join()
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun before() {
|
||||
connection = getConnextion()
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
fun afterAll() {
|
||||
val downSQL = File(this::class.java.getResource("/fixtures/down.sql").toURI())
|
||||
getConnextion().connect().sendQuery(downSQL.readText()).join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getObject() {
|
||||
val obj: ObjTest? = connection.selectOne<Int?, ObjTest>("select to_json(a) from test a limit 1")
|
||||
|
||||
Reference in New Issue
Block a user