diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..52c31a1
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,119 @@
+# This workflow will build a Java project with Gradle
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
+
+name: Tests
+
+on:
+ push:
+ branches:
+ - '**'
+ pull_request:
+ branches:
+ - '**'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+
+ - name: Cache Gradle packages
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+ - name: Build
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: build -x test -x ktlintKotlinScriptCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck -x detekt
+ - name: Cleanup Gradle Cache
+ # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
+ # Restoring these files from a GitHub Actions cache might cause problems for future builds.
+ run: |
+ rm -f ~/.gradle/caches/modules-2/modules-2.lock
+ rm -f ~/.gradle/caches/modules-2/gc.properties
+
+ - name: processResources
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: processResources
+ - name: processTestResources
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: processResources
+ - uses: actions/upload-artifact@v2
+ with:
+ name: Build
+ path: build
+
+ testSql:
+ needs: build
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+ - uses: actions/download-artifact@v2
+ with:
+ name: Build
+ path: build
+ - name: TestSql
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: testSql
+
+ test:
+ needs: build
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+ - uses: actions/download-artifact@v2
+ with:
+ name: Build
+ path: build
+ - name: Test
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: test -x testSql
+
+ lint:
+ needs: build
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+ - uses: actions/download-artifact@v2
+ with:
+ name: Build
+ path: build
+ - name: Lint
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: 6.8
+ arguments: ktlintCheck
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 2b2a567..f064c72 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -11,7 +11,7 @@
postgresql
true
org.postgresql.Driver
- jdbc:postgresql://localhost:5433/test
+ jdbc:postgresql://localhost:15432/test
postgresql
diff --git a/README.md b/README.md
index b8aeb3f..8684665 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# DC Project
+[](https://github.com/flecomte/dc-project/actions/workflows/tests.yml)
+
[Installation](./doc/installation)
### Run dockers
diff --git a/build.gradle.kts b/build.gradle.kts
index 4aa8aeb..2e05421 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -56,7 +56,7 @@ buildscript {
}
dependencies {
classpath("com.typesafe:config:1.4.1")
- classpath("com.github.flecomte:postgres-json:2.1.1")
+ classpath("com.github.flecomte:postgres-json:2.1.2")
}
}
@@ -71,7 +71,7 @@ val migration by tasks.registering {
dependsOn(tasks.named("composeUp"))
doLast {
- val config = ConfigFactory.parseFile(file("$buildDir/../src/main/resources/application.conf")).resolve()
+ val config = ConfigFactory.parseFile(file("$buildDir/resources/main/application.conf")).resolve()
val connection = Connection(
host = config.getString("db.host"),
port = config.getInt("db.port"),
@@ -81,8 +81,8 @@ val migration by tasks.registering {
)
Migrations(
connection,
- file("$buildDir/../src/main/resources/sql/migrations").toURI(),
- file("$buildDir/../src/main/resources/sql/functions").toURI()
+ file("$buildDir/resources/main/sql/migrations").toURI(),
+ file("$buildDir/resources/main/sql/functions").toURI()
).run {
run()
}
@@ -94,7 +94,7 @@ val migrationTest by tasks.registering {
dependsOn(tasks.named("testComposeUp"))
finalizedBy(tasks.named("testComposeDown"))
doLast {
- val config = ConfigFactory.parseFile(file("$buildDir/../src/test/resources/application-test.conf")).resolve()
+ val config = ConfigFactory.parseFile(file("$buildDir/resources/test/application-test.conf")).resolve()
val connection = Connection(
host = config.getString("db.host"),
port = config.getInt("db.port"),
@@ -104,8 +104,8 @@ val migrationTest by tasks.registering {
)
Migrations(
connection,
- file("$buildDir/../src/main/resources/sql/migrations").toURI(),
- file("$buildDir/../src/main/resources/sql/functions").toURI()
+ file("$buildDir/resources/main/sql/migrations").toURI(),
+ file("$buildDir/resources/main/sql/functions").toURI()
).run {
run()
connection.disconnect()
@@ -115,11 +115,13 @@ val migrationTest by tasks.registering {
val testSql by tasks.registering {
group = "verification"
+ dependsOn(tasks.named("processResources"))
+ dependsOn(tasks.named("processTestResources"))
dependsOn(tasks.named("testComposeUp"))
finalizedBy(tasks.named("testComposeDown"))
doLast {
- val config = ConfigFactory.parseFile(file("$buildDir/../src/test/resources/application-test.conf")).resolve()
+ val config = ConfigFactory.parseFile(file("$buildDir/resources/test/application-test.conf")).resolve()
val connection = Connection(
host = config.getString("db.host"),
@@ -131,16 +133,14 @@ val testSql by tasks.registering {
Migrations(
connection,
- file("$buildDir/../src/main/resources/sql/migrations").toURI(),
- file("$buildDir/../src/main/resources/sql/functions").toURI(),
- file("$buildDir/../src/test/sql/fixtures").toURI()
- ).run {
- run()
- }
+ file("$buildDir/resources/main/sql/migrations").toURI(),
+ file("$buildDir/resources/main/sql/functions").toURI(),
+ file("$buildDir/resources/test/sql/fixtures").toURI()
+ ).run()
Requester.RequesterFactory(
connection = connection,
- queriesDirectory = file("$buildDir/../src/test/sql").toURI()
+ queriesDirectory = file("$buildDir/resources/test/sql").toURI()
).createRequester().run {
getQueries().map {
try {
@@ -267,6 +267,7 @@ tasks.jacocoTestReport {
detekt {
buildUponDefaultConfig = true // preconfigure defaults
+ ignoreFailures = true
// config = files("$projectDir/config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
// baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
@@ -281,6 +282,7 @@ detekt {
tasks.withType {
// Target version of the generated JVM bytecode. It is used for type resolution.
this.jvmTarget = "11"
+ ignoreFailures = true
}
val setMaxMapCount = tasks.create("setMaxMapCount") {
@@ -293,7 +295,12 @@ val setMaxMapCount = tasks.create("setMaxMapCount") {
}
}
}
-tasks.named("testComposeUp").configure { dependsOn(setMaxMapCount) }
+
+tasks.named("testComposeUp").configure {
+ if (OperatingSystem.current().isWindows) {
+ dependsOn(setMaxMapCount)
+ }
+}
dependencyCheck {
formats = listOf(ReportGenerator.Format.HTML, ReportGenerator.Format.XML)
@@ -327,7 +334,7 @@ dependencies {
implementation("net.pearx.kasechange:kasechange-jvm:1.3.0")
implementation("com.auth0:java-jwt:3.12.0")
implementation("com.github.jasync-sql:jasync-postgresql:1.1.6")
- implementation("com.github.flecomte:postgres-json:2.1.1")
+ implementation("com.github.flecomte:postgres-json:2.1.2")
implementation("com.sendgrid:sendgrid-java:4.7.1")
implementation("io.lettuce:lettuce-core:5.3.6.RELEASE") // TODO update to 6.0.2
implementation("com.rabbitmq:amqp-client:5.10.0")
diff --git a/src/main/kotlin/fr/dcproject/component/citizen/routes/GetCurrentCitizen.kt b/src/main/kotlin/fr/dcproject/component/citizen/routes/GetCurrentCitizen.kt
index c6a5fc5..d0b4d3d 100644
--- a/src/main/kotlin/fr/dcproject/component/citizen/routes/GetCurrentCitizen.kt
+++ b/src/main/kotlin/fr/dcproject/component/citizen/routes/GetCurrentCitizen.kt
@@ -34,7 +34,7 @@ object GetCurrentCitizen {
object {
val firstName: String = n.firstName
val lastName: String = n.lastName
- }
+ }
}
val email: String = citizen.email
val birthday: String = citizen.birthday.run {
diff --git a/src/test/kotlin/integration/Article routes.kt b/src/test/kotlin/integration/Article routes.kt
index 1faa3ba..5c9140b 100644
--- a/src/test/kotlin/integration/Article routes.kt
+++ b/src/test/kotlin/integration/Article routes.kt
@@ -1,22 +1,22 @@
package integration
-import integration.steps.then.`And have property`
-import integration.steps.then.`And the response should contain pattern`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
-import integration.steps.then.`whish contains`
-import integration.steps.then.and
import integration.steps.given.`Given I have article created by workgroup`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have articles`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And have property`
import integration.steps.then.`And the response should contain list`
+import integration.steps.then.`And the response should contain pattern`
+import integration.steps.then.`And the response should not be null`
import integration.steps.then.`And the response should not contain`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.`whish contains`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags
@@ -84,18 +84,20 @@ class `Article routes` : BaseTest() {
`Given I have citizen`("John", "Doe")
`When I send a POST request`("/articles") {
`authenticated as`("John", "Doe")
- `with body`("""
- {
- "versionId": "09c418b6-63ba-448b-b38b-502b41cd500e",
- "title": "title2",
- "anonymous": false,
- "content": "content2",
- "description": "description2",
- "tags": [
- "green"
- ]
- }
- """)
+ `with body`(
+ """
+ {
+ "versionId": "09c418b6-63ba-448b-b38b-502b41cd500e",
+ "title": "title2",
+ "anonymous": false,
+ "content": "content2",
+ "description": "description2",
+ "tags": [
+ "green"
+ ]
+ }
+ """
+ )
} `Then the response should be` OK and {
`And the response should not be null`()
`And have property`("$.versionId") `whish contains` "09c418b6-63ba-448b-b38b-502b41cd500e"
diff --git a/src/test/kotlin/integration/Citizen routes.kt b/src/test/kotlin/integration/Citizen routes.kt
index b5c2d9b..602212b 100644
--- a/src/test/kotlin/integration/Citizen routes.kt
+++ b/src/test/kotlin/integration/Citizen routes.kt
@@ -1,16 +1,16 @@
package integration
import integration.steps.`when`.Validate
-import integration.steps.then.`And have property`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
-import integration.steps.then.`whish contains`
-import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And have property`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.`whish contains`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -66,12 +66,14 @@ class `Citizen routes` : BaseTest() {
`Given I have citizen`("Georges", "Charpak", id = "0c966522-4071-43e5-a3ca-cfff2557f2cf")
`When I send a PUT request`("/citizens/0c966522-4071-43e5-a3ca-cfff2557f2cf/password/change") {
`authenticated as`("Georges", "Charpak")
- `with body`("""
- {
- "oldPassword": "azerty",
- "newPassword": "qwerty"
- }
- """)
+ `with body`(
+ """
+ {
+ "oldPassword": "azerty",
+ "newPassword": "qwerty"
+ }
+ """
+ )
} `Then the response should be` Created
}
}
@@ -82,12 +84,14 @@ class `Citizen routes` : BaseTest() {
`Given I have citizen`("Louis", "Breguet", id = "6cf2a19d-d15d-4ee5-b2a9-907afd26b525")
`When I send a PUT request`("/citizens/6cf2a19d-d15d-4ee5-b2a9-907afd26b525/password/change", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Louis", "Breguet")
- `with body`("""
- {
- "plup": "azerty",
- "gloup": "qwerty"
- }
- """)
+ `with body`(
+ """
+ {
+ "plup": "azerty",
+ "gloup": "qwerty"
+ }
+ """
+ )
} `Then the response should be` BadRequest
}
}
diff --git a/src/test/kotlin/integration/Comment articles routes.kt b/src/test/kotlin/integration/Comment articles routes.kt
index ba8e850..74e8107 100644
--- a/src/test/kotlin/integration/Comment articles routes.kt
+++ b/src/test/kotlin/integration/Comment articles routes.kt
@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
-import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -30,11 +30,13 @@ class `Comment articles routes` : BaseTest() {
`Given I have article`(id = "aa16c635-28da-46f0-9a89-934eef88c7ca")
`When I send a POST request`("/articles/aa16c635-28da-46f0-9a89-934eef88c7ca/comments") {
`authenticated as`("Michael", "Faraday")
- `with body`("""
- {
- "content": "Hello mister"
- }
- """)
+ `with body`(
+ """
+ {
+ "content": "Hello mister"
+ }
+ """
+ )
} `Then the response should be` Created and {
`And the response should not be null`()
`And the response should contain`("$.target.id", "aa16c635-28da-46f0-9a89-934eef88c7ca")
@@ -99,11 +101,13 @@ class `Comment articles routes` : BaseTest() {
`Given I have comment on article`(article = "bb05e4a3-55a1-4088-85e7-8d8c23be29b1", createdBy = Name("Hubert", "Reeves"), id = "fd30d20f-656c-42c6-8955-f61c04537464")
`When I send a PUT request`("/comments/fd30d20f-656c-42c6-8955-f61c04537464") {
`authenticated as`("Hubert", "Reeves")
- `with body`("""
- {
- "content": "Hello boy"
- }
- """)
+ `with body`(
+ """
+ {
+ "content": "Hello boy"
+ }
+ """
+ )
} `Then the response should be` OK and {
`And the response should not be null`()
`And the response should contain`("$.content", "Hello boy")
diff --git a/src/test/kotlin/integration/Comment constitutions routes.kt b/src/test/kotlin/integration/Comment constitutions routes.kt
index eaa2020..8af64ed 100644
--- a/src/test/kotlin/integration/Comment constitutions routes.kt
+++ b/src/test/kotlin/integration/Comment constitutions routes.kt
@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
-import integration.steps.then.`And the response should contain list`
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
-import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on constitution`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should contain list`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -30,11 +30,13 @@ class `Comment constitutions routes` : BaseTest() {
`Given I have constitution`(id = "1707c287-a472-4a62-89f2-9e85030e915c")
`When I send a POST request`("/constitutions/1707c287-a472-4a62-89f2-9e85030e915c/comments") {
`authenticated as`("Nicolas", "Copernic")
- `with body`("""
- {
- "content": "Hello mister"
- }
- """)
+ `with body`(
+ """
+ {
+ "content": "Hello mister"
+ }
+ """
+ )
} `Then the response should be` Created and {
`And the response should not be null`()
}
diff --git a/src/test/kotlin/integration/Comment routes.kt b/src/test/kotlin/integration/Comment routes.kt
index b06a811..1a1143e 100644
--- a/src/test/kotlin/integration/Comment routes.kt
+++ b/src/test/kotlin/integration/Comment routes.kt
@@ -1,13 +1,13 @@
package integration
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
-import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags
diff --git a/src/test/kotlin/integration/Constitution routes.kt b/src/test/kotlin/integration/Constitution routes.kt
index da77887..01de75b 100644
--- a/src/test/kotlin/integration/Constitution routes.kt
+++ b/src/test/kotlin/integration/Constitution routes.kt
@@ -1,18 +1,18 @@
package integration
import integration.steps.`when`.Validate
-import integration.steps.then.`And have property`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
-import integration.steps.then.`whish contains`
-import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`Given I have constitutions`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And have property`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.`whish contains`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -66,18 +66,20 @@ class `Constitution routes` : BaseTest() {
`Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions") {
`authenticated as`("Henri", "Poincaré")
- `with body`("""
- {
- "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
- "title":"Hello world!",
- "anonymous":true,
- "titles":[
- {
- "name":"plop"
- }
- ]
- }
- """)
+ `with body`(
+ """
+ {
+ "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
+ "title":"Hello world!",
+ "anonymous":true,
+ "titles":[
+ {
+ "name":"plop"
+ }
+ ]
+ }
+ """
+ )
} `Then the response should be` Created and {
`And the response should not be null`()
`And have property`("$.versionId") `whish contains` "15814bb6-8d90-4c6a-a456-c3939a8ec75e"
@@ -92,19 +94,21 @@ class `Constitution routes` : BaseTest() {
`Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Henri", "Poincaré")
- `with body`("""
- {
- "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
- "title":"Hello world!",
- "anonymous":true,
- "titles":[
- {
- "name":"plop",
- "wrongField":0
- }
- ]
- }
- """)
+ `with body`(
+ """
+ {
+ "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
+ "title":"Hello world!",
+ "anonymous":true,
+ "titles":[
+ {
+ "name":"plop",
+ "wrongField":0
+ }
+ ]
+ }
+ """
+ )
} `Then the response should be` BadRequest
}
}
diff --git a/src/test/kotlin/integration/Follow articles routes.kt b/src/test/kotlin/integration/Follow articles routes.kt
index 4edefd2..1c79b9f 100644
--- a/src/test/kotlin/integration/Follow articles routes.kt
+++ b/src/test/kotlin/integration/Follow articles routes.kt
@@ -1,18 +1,18 @@
package integration
-import integration.steps.then.`And the response should be null`
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
-import integration.steps.then.and
import integration.steps.given.`And follow article`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
+import integration.steps.then.`And the response should be null`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK
diff --git a/src/test/kotlin/integration/Follow constitutions routes.kt b/src/test/kotlin/integration/Follow constitutions routes.kt
index fc20797..5c28b17 100644
--- a/src/test/kotlin/integration/Follow constitutions routes.kt
+++ b/src/test/kotlin/integration/Follow constitutions routes.kt
@@ -1,18 +1,18 @@
package integration
-import integration.steps.then.`And the response should be null`
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
-import integration.steps.then.and
import integration.steps.given.`And follow constitution`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
+import integration.steps.then.`And the response should be null`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK
diff --git a/src/test/kotlin/integration/Login routes.kt b/src/test/kotlin/integration/Login routes.kt
index 6489136..7336f9b 100644
--- a/src/test/kotlin/integration/Login routes.kt
+++ b/src/test/kotlin/integration/Login routes.kt
@@ -1,12 +1,12 @@
package integration
-import integration.steps.then.`And the response should not be null`
-import integration.steps.then.`Then the response should be`
-import integration.steps.then.`and should contains`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should not be null`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.`and should contains`
import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK
@@ -23,15 +23,17 @@ class `Login routes` : BaseTest() {
withIntegrationApplication {
`Given I have citizen`("Niels", "Bohr")
`When I send a POST request`("/login") {
- `with body`("""
- {
- "username": "niels-bohr",
- "password": "azerty"
- }
- """)
+ `with body`(
+ """
+ {
+ "username": "niels-bohr",
+ "password": "azerty"
+ }
+ """
+ )
} `Then the response should be` OK and {
`And the response should not be null`() `and should contains` "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9."
- //TODO valid requestBody
+ // TODO valid requestBody
}
}
}
@@ -42,12 +44,14 @@ class `Login routes` : BaseTest() {
`Given I have citizen`("Leonhard", "Euler", "fabrice.lecomte.be@gmail.com", id = "c606110c-ff0e-4d09-a79e-74632d7bf7bd")
`When I send a POST request`("/auth/passwordless") {
`authenticated as`("Leonhard", "Euler")
- `with body`("""
- {
- "url": "https://dc-project.fr/password/reset",
- "email": "fabrice.lecomte.be@gmail.com"
- }
- """)
+ `with body`(
+ """
+ {
+ "url": "https://dc-project.fr/password/reset",
+ "email": "fabrice.lecomte.be@gmail.com"
+ }
+ """
+ )
} `Then the response should be` NoContent
}
}
diff --git a/src/test/kotlin/integration/Opinion routes.kt b/src/test/kotlin/integration/Opinion routes.kt
index 7a3815c..6abc93c 100644
--- a/src/test/kotlin/integration/Opinion routes.kt
+++ b/src/test/kotlin/integration/Opinion routes.kt
@@ -1,18 +1,18 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
-import integration.steps.then.`And the response should contain list`
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
-import integration.steps.then.and
import integration.steps.given.`Given I have an opinion choice`
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have opinion on article`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should contain list`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -55,13 +55,15 @@ class `Opinion routes` : BaseTest() {
`Given I have article`(id = "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b", createdBy = Name("Isaac", "Newton"))
`When I send a PUT request`("/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/opinions") {
`authenticated as`("Isaac", "Newton")
- `with body`("""
- {
- "ids": [
- "0f4f1721-3136-44f1-9f31-1459f3317b15"
- ]
- }
- """)
+ `with body`(
+ """
+ {
+ "ids": [
+ "0f4f1721-3136-44f1-9f31-1459f3317b15"
+ ]
+ }
+ """
+ )
} `Then the response should be` Created
}
}
diff --git a/src/test/kotlin/integration/Register routes.kt b/src/test/kotlin/integration/Register routes.kt
index c78cdeb..52c4ae5 100644
--- a/src/test/kotlin/integration/Register routes.kt
+++ b/src/test/kotlin/integration/Register routes.kt
@@ -22,17 +22,19 @@ class `Register routes` : BaseTest() {
fun `I can register`() {
withIntegrationApplication {
`When I send a POST request`("/register") {
- `with body`("""
- {
- "name": {"firstName":"George", "lastName":"MICHEL"},
- "birthday": "2001-01-01",
- "user":{
- "username": "george-junior",
- "password": "azerty"
- },
- "email": "george-junior@gmail.com"
- }
- """)
+ `with body`(
+ """
+ {
+ "name": {"firstName":"George", "lastName":"MICHEL"},
+ "birthday": "2001-01-01",
+ "user":{
+ "username": "george-junior",
+ "password": "azerty"
+ },
+ "email": "george-junior@gmail.com"
+ }
+ """
+ )
} `Then the response should be` OK and {
`And the response should not be null`()
`And the response should contain pattern`("$.token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.")
@@ -44,16 +46,18 @@ class `Register routes` : BaseTest() {
fun `I cannot register if no username was sent`() {
withIntegrationApplication {
`When I send a POST request`("/register", Validate.ALL - Validate.REQUEST_BODY) {
- `with body`("""
- {
- "name": {"firstName":"George2", "lastName":"MICHEL2"},
- "birthday": "2001-01-01",
- "user":{
- "password": ""
- },
- "email": "george-junior@gmail.com"
- }
- """)
+ `with body`(
+ """
+ {
+ "name": {"firstName":"George2", "lastName":"MICHEL2"},
+ "birthday": "2001-01-01",
+ "user":{
+ "password": ""
+ },
+ "email": "george-junior@gmail.com"
+ }
+ """
+ )
} `Then the response should be` BadRequest and {
`And the response should be null`()
}
diff --git a/src/test/kotlin/integration/Vote routes.kt b/src/test/kotlin/integration/Vote routes.kt
index 55c6263..ec734b8 100644
--- a/src/test/kotlin/integration/Vote routes.kt
+++ b/src/test/kotlin/integration/Vote routes.kt
@@ -1,12 +1,9 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
-import integration.steps.then.and
import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article`
@@ -14,6 +11,9 @@ import integration.steps.given.`Given I have constitution`
import integration.steps.given.`Given I have vote +1 on article`
import integration.steps.given.`Given I have vote -1 on article`
import integration.steps.given.`authenticated as`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag
@@ -31,11 +31,13 @@ class `Vote routes` : BaseTest() {
`Given I have article`(id = "835c5101-ca39-4038-a4e6-da6ee62ca6d5")
`When I send a PUT request`("/articles/835c5101-ca39-4038-a4e6-da6ee62ca6d5/vote") {
`authenticated as`("Thalès", "Milet")
- `with body`("""
- {
- "note": 1
- }
- """)
+ `with body`(
+ """
+ {
+ "note": 1
+ }
+ """
+ )
} `Then the response should be` Created
}
}
@@ -47,11 +49,13 @@ class `Vote routes` : BaseTest() {
`Given I have constitution`(id = "76e79c89-efc1-492d-9e8f-dc9717363a11")
`When I send a PUT request`("/constitutions/76e79c89-efc1-492d-9e8f-dc9717363a11/vote") {
`authenticated as`("Gregor", "Mendel")
- `with body`("""
- {
- "note": 1
- }
- """)
+ `with body`(
+ """
+ {
+ "note": 1
+ }
+ """
+ )
} `Then the response should be` Created
}
}
@@ -102,11 +106,13 @@ class `Vote routes` : BaseTest() {
)
`When I send a PUT request`("/comments/e793eccc-456b-4450-a292-46d592229b74/vote") {
`authenticated as`("Antoine", "Lavoisier")
- `with body`("""
- {
- "note": -1
- }
- """)
+ `with body`(
+ """
+ {
+ "note": -1
+ }
+ """
+ )
} `Then the response should be` Created and {
`And the response should contain`("$.down", 1)
}
diff --git a/src/test/kotlin/integration/Workgroup routes.kt b/src/test/kotlin/integration/Workgroup routes.kt
index ad67f4e..5f6131e 100644
--- a/src/test/kotlin/integration/Workgroup routes.kt
+++ b/src/test/kotlin/integration/Workgroup routes.kt
@@ -1,21 +1,21 @@
package integration
import fr.dcproject.component.citizen.database.CitizenI.Name
-import integration.steps.then.`And the response should be null`
-import integration.steps.then.`And the response should contain list`
-import integration.steps.then.`And the response should contain`
-import integration.steps.then.`Then the response should be`
import integration.steps.`when`.`When I send a DELETE request`
import integration.steps.`when`.`When I send a GET request`
import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body`
-import integration.steps.then.and
import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`With members`
import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content`
+import integration.steps.then.`And the response should be null`
+import integration.steps.then.`And the response should contain list`
+import integration.steps.then.`And the response should contain`
+import integration.steps.then.`Then the response should be`
+import integration.steps.then.and
import integration.steps.then.`And have property`
import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent
@@ -68,14 +68,16 @@ class `Workgroup routes` : BaseTest() {
`Given I have citizen`("Werner", "Heisenberg")
`When I send a POST request`("/workgroups") {
`authenticated as`("Werner", "Heisenberg")
- `with body`("""
- {
- "id":"f496d86d-6654-4068-91ff-90e1dbcc5f38",
- "name":"Les Bouffons",
- "description":"La vie est belle",
- "anonymous":false
- }
- """)
+ `with body`(
+ """
+ {
+ "id":"f496d86d-6654-4068-91ff-90e1dbcc5f38",
+ "name":"Les Bouffons",
+ "description":"La vie est belle",
+ "anonymous":false
+ }
+ """
+ )
} `Then the response should be` Created and {
`And the response should contain`("$.id", "f496d86d-6654-4068-91ff-90e1dbcc5f38")
`And the response should contain`("$.name", "Les Bouffons")
@@ -171,18 +173,20 @@ class `Workgroup routes` : BaseTest() {
`Given I have workgroup`("b0ea1922-3bc6-44e2-aa7c-40158998cfbb", createdBy = Name("Blaise", "Pascal"))
`When I send a POST request`("/workgroups/b0ea1922-3bc6-44e2-aa7c-40158998cfbb/members") {
`authenticated as`("Blaise", "Pascal")
- `with body`("""
- [
- {
- "citizen": {"id":"6d883fe7-5fc0-4a50-8858-72230673eba4"},
- "roles": ["MASTER"]
- },
- {
- "citizen": {"id":"b5bac515-45d4-4aeb-9b6d-2627a0bbc419"},
- "roles": ["MASTER"]
- }
- ]
- """)
+ `with body`(
+ """
+ [
+ {
+ "citizen": {"id":"6d883fe7-5fc0-4a50-8858-72230673eba4"},
+ "roles": ["MASTER"]
+ },
+ {
+ "citizen": {"id":"b5bac515-45d4-4aeb-9b6d-2627a0bbc419"},
+ "roles": ["MASTER"]
+ }
+ ]
+ """
+ )
} `Then the response should be` Created
}
}
@@ -231,18 +235,20 @@ class `Workgroup routes` : BaseTest() {
}
`When I send a PUT request`("/workgroups/784fe6bc-7635-4ae2-b080-3a4743b998bf/members") {
`authenticated as`("Leon", "Foucault")
- `with body`("""
- [
- {
- "citizen": {"id":"be3b0926-8628-4426-804a-75188a6eb315"},
- "roles": ["MASTER"]
- },
- {
- "citizen": {"id":"b49e20c1-8393-45d6-a6a0-3fa5c71cbdc1"},
- "roles": ["MASTER"]
- }
- ]
- """)
+ `with body`(
+ """
+ [
+ {
+ "citizen": {"id":"be3b0926-8628-4426-804a-75188a6eb315"},
+ "roles": ["MASTER"]
+ },
+ {
+ "citizen": {"id":"b49e20c1-8393-45d6-a6a0-3fa5c71cbdc1"},
+ "roles": ["MASTER"]
+ }
+ ]
+ """
+ )
} `Then the response should be` OK and {
`And the response should contain list`("$", 2, 2)
`And the response should contain`("$.[0]citizen.id", "be3b0926-8628-4426-804a-75188a6eb315")
diff --git a/src/test/kotlin/unit/security/Vote Access Control.kt b/src/test/kotlin/unit/security/Vote Access Control.kt
index d04dbb4..51dfa6c 100644
--- a/src/test/kotlin/unit/security/Vote Access Control.kt
+++ b/src/test/kotlin/unit/security/Vote Access Control.kt
@@ -11,6 +11,7 @@ import fr.dcproject.component.citizen.database.CitizenCreator
import fr.dcproject.component.citizen.database.CitizenI
import fr.dcproject.component.vote.VoteAccessControl
import fr.dcproject.component.vote.database.VoteForUpdate
+import fr.dcproject.component.vote.database.VoteForView
import org.amshove.kluent.`should be`
import org.joda.time.DateTime
import org.junit.jupiter.api.Tag
@@ -20,7 +21,6 @@ import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT
import java.util.UUID
-import fr.dcproject.component.vote.database.VoteForView
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(CONCURRENT)
diff --git a/src/test/sql/.gitignore b/src/test/resources/sql/.gitignore
similarity index 100%
rename from src/test/sql/.gitignore
rename to src/test/resources/sql/.gitignore
diff --git a/src/test/sql/article.sql b/src/test/resources/sql/article.sql
similarity index 100%
rename from src/test/sql/article.sql
rename to src/test/resources/sql/article.sql
diff --git a/src/test/sql/citizen.sql b/src/test/resources/sql/citizen.sql
similarity index 100%
rename from src/test/sql/citizen.sql
rename to src/test/resources/sql/citizen.sql
diff --git a/src/test/sql/comment.sql b/src/test/resources/sql/comment.sql
similarity index 100%
rename from src/test/sql/comment.sql
rename to src/test/resources/sql/comment.sql
diff --git a/src/test/sql/constitution.sql b/src/test/resources/sql/constitution.sql
similarity index 100%
rename from src/test/sql/constitution.sql
rename to src/test/resources/sql/constitution.sql
diff --git a/src/test/sql/fixtures/1-fixture_user.sql b/src/test/resources/sql/fixtures/1-fixture_user.sql
similarity index 100%
rename from src/test/sql/fixtures/1-fixture_user.sql
rename to src/test/resources/sql/fixtures/1-fixture_user.sql
diff --git a/src/test/sql/fixtures/2-fixture_citizen.sql b/src/test/resources/sql/fixtures/2-fixture_citizen.sql
similarity index 100%
rename from src/test/sql/fixtures/2-fixture_citizen.sql
rename to src/test/resources/sql/fixtures/2-fixture_citizen.sql
diff --git a/src/test/sql/fixtures/3-fixture_workgroup.sql b/src/test/resources/sql/fixtures/3-fixture_workgroup.sql
similarity index 100%
rename from src/test/sql/fixtures/3-fixture_workgroup.sql
rename to src/test/resources/sql/fixtures/3-fixture_workgroup.sql
diff --git a/src/test/sql/fixtures/4-fixture_article.sql b/src/test/resources/sql/fixtures/4-fixture_article.sql
similarity index 100%
rename from src/test/sql/fixtures/4-fixture_article.sql
rename to src/test/resources/sql/fixtures/4-fixture_article.sql
diff --git a/src/test/sql/follow.sql b/src/test/resources/sql/follow.sql
similarity index 100%
rename from src/test/sql/follow.sql
rename to src/test/resources/sql/follow.sql
diff --git a/src/test/sql/opinion.sql b/src/test/resources/sql/opinion.sql
similarity index 100%
rename from src/test/sql/opinion.sql
rename to src/test/resources/sql/opinion.sql
diff --git a/src/test/sql/test.sh b/src/test/resources/sql/test.sh
similarity index 100%
rename from src/test/sql/test.sh
rename to src/test/resources/sql/test.sh
diff --git a/src/test/sql/user.sql b/src/test/resources/sql/user.sql
similarity index 100%
rename from src/test/sql/user.sql
rename to src/test/resources/sql/user.sql
diff --git a/src/test/sql/vote.sql b/src/test/resources/sql/vote.sql
similarity index 100%
rename from src/test/sql/vote.sql
rename to src/test/resources/sql/vote.sql
diff --git a/src/test/sql/workgroup.sql b/src/test/resources/sql/workgroup.sql
similarity index 100%
rename from src/test/sql/workgroup.sql
rename to src/test/resources/sql/workgroup.sql