Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35a8712eef | |||
| b200b3579a |
18
.idea/codeStyles/Project.xml
generated
18
.idea/codeStyles/Project.xml
generated
@@ -2,16 +2,30 @@
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="java.util" withSubpackages="true" static="false" />
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<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_FOR_MEMBERS" value="2147483647" />
|
||||
<option name="IMPORT_NESTED_CLASSES" value="true" />
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<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>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
|
||||
@@ -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>
|
||||
@@ -9,6 +9,7 @@ plugins {
|
||||
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
|
||||
id("org.owasp.dependencycheck") version "6.1.1"
|
||||
id("fr.coppernic.versioning") version "3.2.1"
|
||||
id("com.avast.gradle.docker-compose") version "0.14.0"
|
||||
}
|
||||
|
||||
group = "com.github.flecomte"
|
||||
@@ -27,6 +28,26 @@ 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 {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.31")
|
||||
@@ -34,11 +55,13 @@ dependencies {
|
||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1")
|
||||
implementation("com.github.jasync-sql:jasync-postgresql:1.1.7")
|
||||
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-core:1.2.3")
|
||||
testImplementation("io.mockk:mockk:1.10.6")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.4.30")
|
||||
testImplementation("org.amshove.kluent:kluent:1.65")
|
||||
}
|
||||
|
||||
@@ -47,6 +70,14 @@ val sourcesJar by tasks.creating(Jar::class) {
|
||||
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 {
|
||||
repositories {
|
||||
maven {
|
||||
|
||||
@@ -12,7 +12,7 @@ import fr.postgresjson.entity.Serializable
|
||||
import fr.postgresjson.serializer.Serializer
|
||||
import fr.postgresjson.utils.LoggerDelegate
|
||||
import org.slf4j.Logger
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
typealias SelectOneCallback<T> = QueryResult.(T?) -> Unit
|
||||
typealias SelectCallback<T> = QueryResult.(List<T>) -> Unit
|
||||
@@ -59,7 +59,7 @@ class Connection(
|
||||
it is EntityI && typeReference.type.typeName == it::class.java.name
|
||||
} as R?
|
||||
val result = exec(sql, compileArgs(values))
|
||||
val json = result.rows[0].getString(0)
|
||||
val json = result.rows.firstOrNull()?.getString(0)
|
||||
return if (json === null) {
|
||||
null
|
||||
} else {
|
||||
@@ -280,11 +280,14 @@ class Connection(
|
||||
logger?.debug("Query executed in $duration ms \n{}", args)
|
||||
return result
|
||||
} catch (e: Throwable) {
|
||||
logger?.info("""
|
||||
logger?.info(
|
||||
"""
|
||||
Query Error:
|
||||
${sql.prependIndent()},
|
||||
${values.joinToString(", ").prependIndent()}
|
||||
""".trimIndent(), e)
|
||||
""".trimIndent(),
|
||||
e
|
||||
)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package fr.postgresjson.connexion
|
||||
import fr.postgresjson.utils.searchSqlFiles
|
||||
import java.net.URI
|
||||
import fr.postgresjson.definition.Function as DefinitionFunction
|
||||
import fr.postgresjson.definition.Function as FunctionDefinition
|
||||
import fr.postgresjson.definition.Query as QueryDefinition
|
||||
|
||||
class Requester(
|
||||
@@ -52,7 +51,7 @@ class Requester(
|
||||
fun addFunction(functionsDirectory: URI): Requester {
|
||||
functionsDirectory.searchSqlFiles()
|
||||
.forEach {
|
||||
if (it is FunctionDefinition) {
|
||||
if (it is DefinitionFunction) {
|
||||
addFunction(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package fr.postgresjson.entity
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
interface EntityRefI<T> : EntityI {
|
||||
val id: T
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.github.jasync.sql.db.postgresql.exceptions.GenericDatabaseException
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.migration.Migration.Action
|
||||
import fr.postgresjson.migration.Migration.Status
|
||||
import java.util.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.Date
|
||||
import java.util.concurrent.CompletionException
|
||||
import fr.postgresjson.definition.Function as DefinitionFunction
|
||||
|
||||
data class Function(
|
||||
|
||||
@@ -3,7 +3,7 @@ package fr.postgresjson.migration
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.entity.Entity
|
||||
import fr.postgresjson.migration.Migration.Action
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
|
||||
data class MigrationScript(
|
||||
val name: String,
|
||||
|
||||
@@ -2,7 +2,6 @@ package fr.postgresjson.migration
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.definition.Migration as DefinitionMigration
|
||||
import fr.postgresjson.entity.Entity
|
||||
import fr.postgresjson.migration.Migration.Action
|
||||
import fr.postgresjson.migration.Migration.Status
|
||||
@@ -11,8 +10,9 @@ import fr.postgresjson.utils.searchSqlFiles
|
||||
import org.slf4j.Logger
|
||||
import java.io.FileNotFoundException
|
||||
import java.net.URI
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import fr.postgresjson.definition.Function as DefinitionFunction
|
||||
import fr.postgresjson.definition.Migration as DefinitionMigration
|
||||
|
||||
class MigrationEntity(
|
||||
val filename: String,
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package fr.postgresjson
|
||||
|
||||
import fr.postgresjson.connexion.Paginated
|
||||
import fr.postgresjson.entity.UuidEntity
|
||||
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.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ConnectionTest() : TestAbstract() {
|
||||
@@ -26,7 +28,8 @@ class ConnectionTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun getExistingObject() {
|
||||
val objs: List<ObjTest2> = connection.select("""
|
||||
val objs: List<ObjTest2> = connection.select(
|
||||
"""
|
||||
select
|
||||
json_agg(j)
|
||||
FROM (
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
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.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class EntityTest() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.amshove.kluent.shouldThrow
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class MigrationTest() : TestAbstract() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import fr.postgresjson.entity.UuidEntity
|
||||
import org.junit.Assert
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
class RequesterTest : TestAbstract() {
|
||||
class ObjTest(var name: String, id: UUID = UUID.fromString("5623d902-3067-42f3-bfd9-095dbb12c29f")) : UuidEntity(id)
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
internal class SerializerTest {
|
||||
|
||||
Reference in New Issue
Block a user