5 Commits
2.0.0 ... 2.1.2

Author SHA1 Message Date
4b28f64c43 Sort sql files on walk 2021-03-20 14:33:18 +01:00
35a8712eef fix select on query with no result 2021-02-27 01:29:21 +01:00
b200b3579a Improve gradle tasks 2021-02-27 00:19:30 +01:00
a13ca2d954 update dependencies 2021-02-26 23:00:41 +01:00
36ed678c5a Add disconnect method 2021-02-26 23:00:29 +01:00
29 changed files with 145 additions and 113 deletions

View File

@@ -2,16 +2,30 @@
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS"> <option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value> <value>
<package name="java.util" withSubpackages="true" static="false" /> <package name="" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value> </value>
</option> </option>
<option name="SPACE_BEFORE_EXTEND_COLON" value="false" /> <option name="SPACE_BEFORE_EXTEND_COLON" value="false" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" /> <option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="IMPORT_NESTED_CLASSES" value="true" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings> </JetCodeStyleSettings>
<codeStyleSettings language="kotlin"> <codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CALL_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<indentOptions> <indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" /> <option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions> </indentOptions>

View File

@@ -1,34 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test and Publish To MavenLocal" type="GradleRunConfiguration" factoryName="Gradle" singleton="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="publishToMavenLocal" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" />
</ENTRIES>
</extension>
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Lint" run_configuration_type="GradleRunConfiguration" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="tests" run_configuration_type="JUnit" />
</method>
</configuration>
</component>

View File

@@ -4,11 +4,12 @@ plugins {
jacoco jacoco
id("maven-publish") id("maven-publish")
id("org.jetbrains.kotlin.jvm") version "1.3.50" kotlin("jvm") version "1.4.30"
id("org.jlleitschuh.gradle.ktlint") version "8.2.0" id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
id("org.owasp.dependencycheck") version "5.1.0" id("org.owasp.dependencycheck") version "6.1.1"
id("fr.coppernic.versioning") version "3.1.2" id("fr.coppernic.versioning") version "3.2.1"
id("com.avast.gradle.docker-compose") version "0.14.0"
} }
group = "com.github.flecomte" group = "com.github.flecomte"
@@ -27,19 +28,41 @@ tasks.withType<KotlinCompile> {
} }
} }
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
jvmTarget = "1.8"
}
tasks.test {
useJUnit()
useJUnitPlatform()
systemProperty("junit.jupiter.execution.parallel.enabled", true)
finalizedBy(tasks.ktlintCheck)
}
tasks.publishToMavenLocal {
dependsOn(tasks.test)
}
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.31") implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.31")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.9") implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1")
implementation("com.github.jasync-sql:jasync-postgresql:1.0.7") implementation("com.github.jasync-sql:jasync-postgresql:1.1.7")
implementation("org.slf4j:slf4j-api:1.7.26") implementation("org.slf4j:slf4j-api:1.7.30")
implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.0")
testImplementation("ch.qos.logback:logback-classic:1.2.3") testImplementation("ch.qos.logback:logback-classic:1.2.3")
testImplementation("ch.qos.logback:logback-core:1.2.3") testImplementation("ch.qos.logback:logback-core:1.2.3")
testImplementation("io.mockk:mockk:1.9") testImplementation("io.mockk:mockk:1.10.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2") testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testImplementation("org.amshove.kluent:kluent:1.47") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.4.30")
testImplementation("org.amshove.kluent:kluent:1.65")
} }
val sourcesJar by tasks.creating(Jar::class) { val sourcesJar by tasks.creating(Jar::class) {
@@ -47,6 +70,14 @@ val sourcesJar by tasks.creating(Jar::class) {
from(sourceSets.getByName("main").allSource) from(sourceSets.getByName("main").allSource)
} }
apply(plugin = "docker-compose")
dockerCompose {
projectName = "postgres-json"
useComposeFiles = listOf("docker-compose.yml")
stopContainers = true
isRequiredBy(project.tasks.test)
}
publishing { publishing {
repositories { repositories {
maven { maven {
@@ -65,4 +96,4 @@ publishing {
artifact(sourcesJar) artifact(sourcesJar)
} }
} }
} }

View File

@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -12,7 +12,7 @@ import fr.postgresjson.entity.Serializable
import fr.postgresjson.serializer.Serializer import fr.postgresjson.serializer.Serializer
import fr.postgresjson.utils.LoggerDelegate import fr.postgresjson.utils.LoggerDelegate
import org.slf4j.Logger import org.slf4j.Logger
import java.util.concurrent.* import java.util.concurrent.CompletableFuture
typealias SelectOneCallback<T> = QueryResult.(T?) -> Unit typealias SelectOneCallback<T> = QueryResult.(T?) -> Unit
typealias SelectCallback<T> = QueryResult.(List<T>) -> Unit typealias SelectCallback<T> = QueryResult.(List<T>) -> Unit
@@ -25,17 +25,26 @@ class Connection(
private val host: String = "localhost", private val host: String = "localhost",
private val port: Int = 5432 private val port: Int = 5432
) : Executable { ) : Executable {
private lateinit var connection: ConnectionPool<PostgreSQLConnection> private var connection: ConnectionPool<PostgreSQLConnection>? = null
private val serializer = Serializer() private val serializer = Serializer()
private val logger: Logger? by LoggerDelegate() private val logger: Logger? by LoggerDelegate()
internal fun connect(): ConnectionPool<PostgreSQLConnection> { internal fun connect(): ConnectionPool<PostgreSQLConnection> {
if (!::connection.isInitialized || !connection.isConnected()) { return connection.let { connectionPool ->
connection = PostgreSQLConnectionBuilder.createConnectionPool( if (connectionPool == null || !connectionPool.isConnected()) {
"jdbc:postgresql://$host:$port/$database?user=$username&password=$password" PostgreSQLConnectionBuilder.createConnectionPool(
) "jdbc:postgresql://$host:$port/$database?user=$username&password=$password"
).also {
connection = it
}
} else {
connectionPool
}
} }
return connection }
fun disconnect() {
connection?.run { disconnect() }
} }
fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f) fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f)
@@ -50,7 +59,7 @@ class Connection(
it is EntityI && typeReference.type.typeName == it::class.java.name it is EntityI && typeReference.type.typeName == it::class.java.name
} as R? } as R?
val result = exec(sql, compileArgs(values)) val result = exec(sql, compileArgs(values))
val json = result.rows[0].getString(0) val json = result.rows.firstOrNull()?.getString(0)
return if (json === null) { return if (json === null) {
null null
} else { } else {
@@ -271,11 +280,14 @@ class Connection(
logger?.debug("Query executed in $duration ms \n{}", args) logger?.debug("Query executed in $duration ms \n{}", args)
return result return result
} catch (e: Throwable) { } catch (e: Throwable) {
logger?.info(""" logger?.info(
"""
Query Error: Query Error:
${sql.prependIndent()}, ${sql.prependIndent()},
${values.joinToString(", ").prependIndent()} ${values.joinToString(", ").prependIndent()}
""".trimIndent(), e) """.trimIndent(),
e
)
throw e throw e
} }
} }

View File

@@ -59,4 +59,4 @@ interface EmbedExecutable {
fun sendQuery(values: Map<String, Any?>): Int fun sendQuery(values: Map<String, Any?>): Int
fun sendQuery(vararg values: Pair<String, Any?>): Int = fun sendQuery(vararg values: Pair<String, Any?>): Int =
sendQuery(values.toMap()) sendQuery(values.toMap())
} }

View File

@@ -52,4 +52,4 @@ interface Executable {
fun exec(sql: String, values: Map<String, Any?>): QueryResult fun exec(sql: String, values: Map<String, Any?>): QueryResult
fun sendQuery(sql: String, values: List<Any?> = emptyList()): Int fun sendQuery(sql: String, values: List<Any?> = emptyList()): Int
fun sendQuery(sql: String, values: Map<String, Any?>): Int fun sendQuery(sql: String, values: Map<String, Any?>): Int
} }

View File

@@ -205,4 +205,4 @@ class Function(val definition: Function, override val connection: Connection) :
return placeholders.joinToString(separator = ", ") return placeholders.joinToString(separator = ", ")
} }
} }

View File

@@ -22,4 +22,4 @@ data class Paginated<T : EntityI>(
fun isLastPage(): Boolean = currentPage >= totalPages fun isLastPage(): Boolean = currentPage >= totalPages
private fun Double.ceil(): Int = ceil(this).toInt() private fun Double.ceil(): Int = ceil(this).toInt()
} }

View File

@@ -106,4 +106,4 @@ class Query(override val name: String, private val sql: String, override val con
override fun sendQuery(values: Map<String, Any?>): Int { override fun sendQuery(values: Map<String, Any?>): Int {
return connection.sendQuery(sql, values) return connection.sendQuery(sql, values)
} }
} }

View File

@@ -3,7 +3,6 @@ package fr.postgresjson.connexion
import fr.postgresjson.utils.searchSqlFiles 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
import fr.postgresjson.definition.Function as FunctionDefinition
import fr.postgresjson.definition.Query as QueryDefinition import fr.postgresjson.definition.Query as QueryDefinition
class Requester( class Requester(
@@ -52,7 +51,7 @@ class Requester(
fun addFunction(functionsDirectory: URI): Requester { fun addFunction(functionsDirectory: URI): Requester {
functionsDirectory.searchSqlFiles() functionsDirectory.searchSqlFiles()
.forEach { .forEach {
if (it is FunctionDefinition) { if (it is DefinitionFunction) {
addFunction(it) addFunction(it)
} }
} }

View File

@@ -87,4 +87,4 @@ class Function(
} }
} }
} }
} }

View File

@@ -32,4 +32,4 @@ class Migration(
class MigrationNotFound(cause: Throwable? = null) : Resource.ParseException("Migration not found in script", cause) class MigrationNotFound(cause: Throwable? = null) : Resource.ParseException("Migration not found in script", cause)
enum class Direction { UP, DOWN } enum class Direction { UP, DOWN }
} }

View File

@@ -30,4 +30,4 @@ class Parameter(val name: String, val type: String, direction: Direction? = Dire
interface ParametersInterface { interface ParametersInterface {
val parameters: List<Parameter> val parameters: List<Parameter>
} }

View File

@@ -14,12 +14,12 @@ class Query(
"""-- *name ?: ?(?<name>[^ \n]+)""" """-- *name ?: ?(?<name>[^ \n]+)"""
.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) .toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE))
.find(script)?.let { .find(script)?.let {
it.groups["name"]?.value?.trim() it.groups["name"]?.value?.trim()
} }
/** Try to get name from the filename */ /** Try to get name from the filename */
private fun getNameFromFile(source: Path): String = source private fun getNameFromFile(source: Path): String = source
.fileName.toString() .fileName.toString()
.substringAfterLast("/") .substringAfterLast("/")
.substringBeforeLast(".sql") .substringBeforeLast(".sql")
} }

View File

@@ -37,4 +37,4 @@ interface Resource {
interface ResourceCollection { interface ResourceCollection {
val parameters: List<Parameter> val parameters: List<Parameter>
} }

View File

@@ -1,7 +1,7 @@
package fr.postgresjson.entity package fr.postgresjson.entity
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.* import java.util.UUID
interface EntityRefI<T> : EntityI { interface EntityRefI<T> : EntityI {
val id: T val id: T
@@ -123,4 +123,4 @@ abstract class UuidEntityExtended<T, UserT : EntityI>(
) : ) :
EntityImp<T, UserT>(updatedBy), EntityImp<T, UserT>(updatedBy),
EntityVersioning<UUID, Int> by UuidEntityVersioning(0), EntityVersioning<UUID, Int> by UuidEntityVersioning(0),
Published<UserT> by EntityPublishedImp(publishedBy) Published<UserT> by EntityPublishedImp(publishedBy)

View File

@@ -4,8 +4,8 @@ import com.github.jasync.sql.db.postgresql.exceptions.GenericDatabaseException
import fr.postgresjson.connexion.Connection import fr.postgresjson.connexion.Connection
import fr.postgresjson.migration.Migration.Action import fr.postgresjson.migration.Migration.Action
import fr.postgresjson.migration.Migration.Status import fr.postgresjson.migration.Migration.Status
import java.util.* import java.util.Date
import java.util.concurrent.* import java.util.concurrent.CompletionException
import fr.postgresjson.definition.Function as DefinitionFunction import fr.postgresjson.definition.Function as DefinitionFunction
data class Function( data class Function(
@@ -93,4 +93,4 @@ data class Function(
infix fun `is different from`(other: DefinitionFunction): Boolean { infix fun `is different from`(other: DefinitionFunction): Boolean {
return other.script != this.up.script return other.script != this.up.script
} }
} }

View File

@@ -3,7 +3,7 @@ package fr.postgresjson.migration
import fr.postgresjson.connexion.Connection import fr.postgresjson.connexion.Connection
import fr.postgresjson.entity.Entity import fr.postgresjson.entity.Entity
import fr.postgresjson.migration.Migration.Action import fr.postgresjson.migration.Migration.Action
import java.util.* import java.util.Date
data class MigrationScript( data class MigrationScript(
val name: String, val name: String,
@@ -62,4 +62,4 @@ data class MigrationScript(
it.doExecute = this.doExecute it.doExecute = this.doExecute
} }
} }
} }

View File

@@ -2,7 +2,6 @@ package fr.postgresjson.migration
import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.core.type.TypeReference
import fr.postgresjson.connexion.Connection import fr.postgresjson.connexion.Connection
import fr.postgresjson.definition.Migration as DefinitionMigration
import fr.postgresjson.entity.Entity import fr.postgresjson.entity.Entity
import fr.postgresjson.migration.Migration.Action import fr.postgresjson.migration.Migration.Action
import fr.postgresjson.migration.Migration.Status import fr.postgresjson.migration.Migration.Status
@@ -11,8 +10,9 @@ import fr.postgresjson.utils.searchSqlFiles
import org.slf4j.Logger import org.slf4j.Logger
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.net.URI import java.net.URI
import java.util.* import java.util.Date
import fr.postgresjson.definition.Function as DefinitionFunction import fr.postgresjson.definition.Function as DefinitionFunction
import fr.postgresjson.definition.Migration as DefinitionMigration
class MigrationEntity( class MigrationEntity(
val filename: String, val filename: String,
@@ -313,4 +313,4 @@ data class Migrations private constructor(
fun status(): Map<String, Int> { fun status(): Map<String, Int> {
TODO("not implemented") TODO("not implemented")
} }
} }

View File

@@ -51,4 +51,4 @@ class Serializer(val mapper: ObjectMapper = jacksonObjectMapper()) {
fun Serializable.serialize(pretty: Boolean = false) = Serializer().serialize(this, pretty) fun Serializable.serialize(pretty: Boolean = false) = Serializer().serialize(this, pretty)
fun List<Serializable>.serialize(pretty: Boolean = false) = Serializer().serialize(this, pretty) fun List<Serializable>.serialize(pretty: Boolean = false) = Serializer().serialize(this, pretty)
inline fun <reified E : Serializable> E.deserialize(json: String) = Serializer().deserialize(json, this) inline fun <reified E : Serializable> E.deserialize(json: String) = Serializer().deserialize(json, this)
inline fun <reified E : Serializable> String.deserialize() = Serializer().deserialize<E>(this) inline fun <reified E : Serializable> String.deserialize() = Serializer().deserialize<E>(this)

View File

@@ -7,4 +7,4 @@ import kotlin.reflect.KProperty
internal class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> { internal class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> {
override fun getValue(thisRef: R, property: KProperty<*>) = LoggerFactory.getLogger(thisRef.javaClass.packageName) override fun getValue(thisRef: R, property: KProperty<*>) = LoggerFactory.getLogger(thisRef.javaClass.packageName)
} }

View File

@@ -47,5 +47,5 @@ fun URI.searchSqlFiles() = sequence<Resource> {
} }
} }
private fun Path.walk(maxDepth: Int = 2147483647, vararg options: FileVisitOption) = Files.walk(this, maxDepth, *options) private fun Path.walk(maxDepth: Int = 2147483647, vararg options: FileVisitOption) = Files.walk(this, maxDepth, *options).sorted()
private fun URI.walk(maxDepth: Int = 2147483647, vararg options: FileVisitOption) = Files.walk(Path.of(this), maxDepth, *options) private fun URI.walk(maxDepth: Int = 2147483647, vararg options: FileVisitOption) = Files.walk(Path.of(this), maxDepth, *options).sorted()

View File

@@ -1,13 +1,15 @@
package fr.postgresjson package fr.postgresjson
import fr.postgresjson.connexion.Paginated import fr.postgresjson.connexion.Paginated
import fr.postgresjson.entity.UuidEntity
import fr.postgresjson.entity.Parameter import fr.postgresjson.entity.Parameter
import org.junit.Assert.* import fr.postgresjson.entity.UuidEntity
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import java.util.* import java.util.UUID
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ConnectionTest() : TestAbstract() { class ConnectionTest() : TestAbstract() {
@@ -26,17 +28,18 @@ class ConnectionTest() : TestAbstract() {
@Test @Test
fun getExistingObject() { fun getExistingObject() {
val objs: List<ObjTest2> = connection.select(""" val objs: List<ObjTest2> = connection.select(
select """
json_agg(j) select
FROM ( json_agg(j)
SELECT FROM (
t.id, t.title, SELECT
t2 as test t.id, t.title,
from test2 t t2 as test
JOIN test t2 ON t.test_id = t2.id from test2 t
) j; JOIN test t2 ON t.test_id = t2.id
""".trimIndent() ) j;
""".trimIndent()
) )
assertNotNull(objs) assertNotNull(objs)
assertEquals(objs.size, 2) assertEquals(objs.size, 2)
@@ -179,4 +182,4 @@ class ConnectionTest() : TestAbstract() {
assertEquals("sec", result.seconde) assertEquals("sec", result.seconde)
assertEquals(123, result.third) assertEquals(123, result.third)
} }
} }

View File

@@ -1,10 +1,17 @@
package fr.postgresjson package fr.postgresjson
import fr.postgresjson.entity.* import fr.postgresjson.entity.Entity
import fr.postgresjson.entity.EntityCreatedAt
import fr.postgresjson.entity.EntityCreatedBy
import fr.postgresjson.entity.EntityI
import fr.postgresjson.entity.EntityUpdatedAt
import fr.postgresjson.entity.EntityUpdatedBy
import fr.postgresjson.entity.Published
import fr.postgresjson.entity.UuidEntityExtended
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import java.util.* import java.util.UUID
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EntityTest() { class EntityTest() {
@@ -24,4 +31,4 @@ class EntityTest() {
assertTrue(obj is EntityCreatedAt) assertTrue(obj is EntityCreatedAt)
assertTrue(obj is EntityUpdatedAt) assertTrue(obj is EntityUpdatedAt)
} }
} }

View File

@@ -10,7 +10,7 @@ import org.amshove.kluent.shouldThrow
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import java.util.* import java.util.UUID
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MigrationTest() : TestAbstract() { class MigrationTest() : TestAbstract() {
@@ -128,4 +128,4 @@ class MigrationTest() : TestAbstract() {
run().size `should be equal to` 1 run().size `should be equal to` 1
} }
} }
} }

View File

@@ -6,7 +6,7 @@ import fr.postgresjson.entity.UuidEntity
import org.junit.Assert import org.junit.Assert
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import java.util.* import java.util.UUID
class RequesterTest : TestAbstract() { class RequesterTest : TestAbstract() {
class ObjTest(var name: String, id: UUID = UUID.fromString("5623d902-3067-42f3-bfd9-095dbb12c29f")) : UuidEntity(id) class ObjTest(var name: String, id: UUID = UUID.fromString("5623d902-3067-42f3-bfd9-095dbb12c29f")) : UuidEntity(id)
@@ -166,4 +166,4 @@ class RequesterTest : TestAbstract() {
assertEquals("myName", obj.name) assertEquals("myName", obj.name)
} }
} }

View File

@@ -10,7 +10,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import java.util.* import java.util.UUID
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class SerializerTest { internal class SerializerTest {
@@ -85,4 +85,4 @@ internal class SerializerTest {
assertEquals("update", objDeserialized.val1) assertEquals("update", objDeserialized.val1)
assertEquals(123, objDeserialized.val2) assertEquals(123, objDeserialized.val2)
} }
} }

View File

@@ -27,4 +27,4 @@ abstract class TestAbstract {
sendQuery(downSQL.readText()).join() sendQuery(downSQL.readText()).join()
}.disconnect() }.disconnect()
} }
} }