18 Commits

Author SHA1 Message Date
1be608e6b2 Add Codacy badge 2021-03-25 02:05:05 +01:00
b13cd5544c add coveralls on CI 2021-03-25 01:53:57 +01:00
104f0fb3fc remove distZip & distTar 2021-03-24 23:06:38 +01:00
b2f40ff421 Restrict CI on pull_request on master 2021-03-24 21:56:58 +01:00
09e81620a1 rollback lintCheck after test, create task testAll 2021-03-24 21:32:28 +01:00
fe953fc967 lintCheck after test 2021-03-24 19:48:14 +01:00
453fd2225c Merge pull request #80
rename openapi file
2021-03-24 19:39:23 +01:00
70fd54d831 Fix destination installation doc 2021-03-24 19:35:11 +01:00
dcf7a2bc06 Rename openapi file 2021-03-24 19:34:39 +01:00
118af0170a Remove unused openapi file 2021-03-24 19:34:00 +01:00
0aa8089a9a Merge pull request #79
Add codefactor badge
2021-03-24 19:29:44 +01:00
fef5f3b396 CodeFactor badge 2021-03-24 19:27:09 +01:00
1838b90ac9 Merge pull request #78
Create CI
2021-03-24 19:12:41 +01:00
73fa2be91f Split CI task test 2021-03-24 19:11:04 +01:00
52183abd08 Lint 2021-03-24 19:08:41 +01:00
e19266d4cc Create CI Action 2021-03-24 19:07:02 +01:00
f458d7b674 Move SQL test files 2021-03-24 19:07:01 +01:00
29d4d6ec25 Merge pull request #77 from flecomte/refactoring-component-and-immutable
Big refactoring
2021-03-24 19:06:06 +01:00
38 changed files with 1870 additions and 3525 deletions

123
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,123 @@
# 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:
pull_request:
branches:
- 'master'
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
- name: Coverage
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.8
arguments: coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
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

2
.idea/dataSources.xml generated
View File

@@ -11,7 +11,7 @@
<driver-ref>postgresql</driver-ref> <driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver> <jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5433/test</jdbc-url> <jdbc-url>jdbc:postgresql://localhost:15432/test</jdbc-url>
</data-source> </data-source>
<data-source source="LOCAL" name="sonar@localhost" uuid="ee78beab-120d-4740-ad21-d4d9e2121d25"> <data-source source="LOCAL" name="sonar@localhost" uuid="ee78beab-120d-4740-ad21-d4d9e2121d25">
<driver-ref>postgresql</driver-ref> <driver-ref>postgresql</driver-ref>

View File

@@ -1,6 +1,12 @@
# DC Project # DC Project
[Installation](./doc/installation) [![CodeFactor](https://www.codefactor.io/repository/github/flecomte/dc-project/badge?s=869dc426625a253a07bea95f9380e23fdb048b94)](https://www.codefactor.io/repository/github/flecomte/dc-project)
[![Tests](https://github.com/flecomte/dc-project/actions/workflows/tests.yml/badge.svg)](https://github.com/flecomte/dc-project/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/flecomte/dc-project/badge.svg?branch=master)](https://coveralls.io/github/flecomte/dc-project?branch=master)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0ec4fe63370148ca956974f90f8d55be)](https://www.codacy.com/gh/flecomte/dc-project/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=flecomte/dc-project&amp;utm_campaign=Badge_Grade)
[Installation](./doc/installation/Installation.md)
### Run dockers ### Run dockers
```bash ```bash

View File

@@ -41,6 +41,7 @@ plugins {
id("net.nemerosa.versioning") version "2.14.0" id("net.nemerosa.versioning") version "2.14.0"
id("io.gitlab.arturbosch.detekt") version "1.16.0-RC1" id("io.gitlab.arturbosch.detekt") version "1.16.0-RC1"
id("com.avast.gradle.docker-compose") version "0.14.0" id("com.avast.gradle.docker-compose") version "0.14.0"
id("com.github.kt3k.coveralls") version "2.8.4"
} }
application { application {
@@ -56,10 +57,13 @@ buildscript {
} }
dependencies { dependencies {
classpath("com.typesafe:config:1.4.1") 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")
} }
} }
tasks.distZip.configure { enabled = false }
tasks.distTar.configure { enabled = false }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
@@ -71,7 +75,7 @@ val migration by tasks.registering {
dependsOn(tasks.named("composeUp")) dependsOn(tasks.named("composeUp"))
doLast { 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( val connection = Connection(
host = config.getString("db.host"), host = config.getString("db.host"),
port = config.getInt("db.port"), port = config.getInt("db.port"),
@@ -81,8 +85,8 @@ val migration by tasks.registering {
) )
Migrations( Migrations(
connection, connection,
file("$buildDir/../src/main/resources/sql/migrations").toURI(), file("$buildDir/resources/main/sql/migrations").toURI(),
file("$buildDir/../src/main/resources/sql/functions").toURI() file("$buildDir/resources/main/sql/functions").toURI()
).run { ).run {
run() run()
} }
@@ -94,7 +98,7 @@ val migrationTest by tasks.registering {
dependsOn(tasks.named("testComposeUp")) dependsOn(tasks.named("testComposeUp"))
finalizedBy(tasks.named("testComposeDown")) finalizedBy(tasks.named("testComposeDown"))
doLast { 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( val connection = Connection(
host = config.getString("db.host"), host = config.getString("db.host"),
port = config.getInt("db.port"), port = config.getInt("db.port"),
@@ -104,8 +108,8 @@ val migrationTest by tasks.registering {
) )
Migrations( Migrations(
connection, connection,
file("$buildDir/../src/main/resources/sql/migrations").toURI(), file("$buildDir/resources/main/sql/migrations").toURI(),
file("$buildDir/../src/main/resources/sql/functions").toURI() file("$buildDir/resources/main/sql/functions").toURI()
).run { ).run {
run() run()
connection.disconnect() connection.disconnect()
@@ -115,11 +119,13 @@ val migrationTest by tasks.registering {
val testSql by tasks.registering { val testSql by tasks.registering {
group = "verification" group = "verification"
dependsOn(tasks.named("processResources"))
dependsOn(tasks.named("processTestResources"))
dependsOn(tasks.named("testComposeUp")) dependsOn(tasks.named("testComposeUp"))
finalizedBy(tasks.named("testComposeDown")) finalizedBy(tasks.named("testComposeDown"))
doLast { 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( val connection = Connection(
host = config.getString("db.host"), host = config.getString("db.host"),
@@ -131,16 +137,14 @@ val testSql by tasks.registering {
Migrations( Migrations(
connection, connection,
file("$buildDir/../src/main/resources/sql/migrations").toURI(), file("$buildDir/resources/main/sql/migrations").toURI(),
file("$buildDir/../src/main/resources/sql/functions").toURI(), file("$buildDir/resources/main/sql/functions").toURI(),
file("$buildDir/../src/test/sql/fixtures").toURI() file("$buildDir/resources/test/sql/fixtures").toURI()
).run { ).run()
run()
}
Requester.RequesterFactory( Requester.RequesterFactory(
connection = connection, connection = connection,
queriesDirectory = file("$buildDir/../src/test/sql").toURI() queriesDirectory = file("$buildDir/resources/test/sql").toURI()
).createRequester().run { ).createRequester().run {
getQueries().map { getQueries().map {
try { try {
@@ -194,6 +198,17 @@ tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
} }
coveralls {
sourceDirs.add("src/main/kotlin")
}
tasks.register("testAll") {
group = "verification"
dependsOn(testSql)
dependsOn(tasks.test)
dependsOn(tasks.ktlintCheck)
}
apply(plugin = "docker-compose") apply(plugin = "docker-compose")
dockerCompose { dockerCompose {
projectName = "dc-project" projectName = "dc-project"
@@ -267,6 +282,7 @@ tasks.jacocoTestReport {
detekt { detekt {
buildUponDefaultConfig = true // preconfigure defaults buildUponDefaultConfig = true // preconfigure defaults
ignoreFailures = true
// config = files("$projectDir/config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior // 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 // baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
@@ -281,6 +297,7 @@ detekt {
tasks.withType<Detekt> { tasks.withType<Detekt> {
// Target version of the generated JVM bytecode. It is used for type resolution. // Target version of the generated JVM bytecode. It is used for type resolution.
this.jvmTarget = "11" this.jvmTarget = "11"
ignoreFailures = true
} }
val setMaxMapCount = tasks.create<Exec>("setMaxMapCount") { val setMaxMapCount = tasks.create<Exec>("setMaxMapCount") {
@@ -293,7 +310,12 @@ val setMaxMapCount = tasks.create<Exec>("setMaxMapCount") {
} }
} }
} }
tasks.named("testComposeUp").configure { dependsOn(setMaxMapCount) }
tasks.named("testComposeUp").configure {
if (OperatingSystem.current().isWindows) {
dependsOn(setMaxMapCount)
}
}
dependencyCheck { dependencyCheck {
formats = listOf(ReportGenerator.Format.HTML, ReportGenerator.Format.XML) formats = listOf(ReportGenerator.Format.HTML, ReportGenerator.Format.XML)
@@ -327,7 +349,7 @@ dependencies {
implementation("net.pearx.kasechange:kasechange-jvm:1.3.0") implementation("net.pearx.kasechange:kasechange-jvm:1.3.0")
implementation("com.auth0:java-jwt:3.12.0") implementation("com.auth0:java-jwt:3.12.0")
implementation("com.github.jasync-sql:jasync-postgresql:1.1.6") 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("com.sendgrid:sendgrid-java:4.7.1")
implementation("io.lettuce:lettuce-core:5.3.6.RELEASE") // TODO update to 6.0.2 implementation("io.lettuce:lettuce-core:5.3.6.RELEASE") // TODO update to 6.0.2
implementation("com.rabbitmq:amqp-client:5.10.0") implementation("com.rabbitmq:amqp-client:5.10.0")

View File

@@ -59,33 +59,33 @@ class ArticleViewManager <A> (private val restClient: RestClient) : ViewManager<
//language=JSON //language=JSON
setJsonEntity( setJsonEntity(
""" """
{ {
"size": 0, "size": 0,
"query": { "query": {
"bool": { "bool": {
"must": { "must": {
"term": { "term": {
"version_id": "${entity.versionId}" "version_id": "${entity.versionId}"
}
}
}
},
"aggs" : {
"total": {
"composite" : {
"sources" : [
{ "version_id": { "terms": {"field": "version_id" } } }
]
}
},
"unique" : {
"cardinality" : {
"field" : "user_ref",
"precision_threshold": 1
}
} }
} }
} }
},
"aggs" : {
"total": {
"composite" : {
"sources" : [
{ "version_id": { "terms": {"field": "version_id" } } }
]
}
},
"unique" : {
"cardinality" : {
"field" : "user_ref",
"precision_threshold": 1
}
}
}
}
""".trimIndent() """.trimIndent()
) )
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +1,22 @@
package integration 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 GET request`
import integration.steps.`when`.`When I send a POST request` import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body` 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 created by workgroup`
import integration.steps.given.`Given I have article` import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have articles` import integration.steps.given.`Given I have articles`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have workgroup` import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`authenticated as` 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 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.`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 io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags import org.junit.jupiter.api.Tags
@@ -84,18 +84,20 @@ class `Article routes` : BaseTest() {
`Given I have citizen`("John", "Doe") `Given I have citizen`("John", "Doe")
`When I send a POST request`("/articles") { `When I send a POST request`("/articles") {
`authenticated as`("John", "Doe") `authenticated as`("John", "Doe")
`with body`(""" `with body`(
{ """
"versionId": "09c418b6-63ba-448b-b38b-502b41cd500e", {
"title": "title2", "versionId": "09c418b6-63ba-448b-b38b-502b41cd500e",
"anonymous": false, "title": "title2",
"content": "content2", "anonymous": false,
"description": "description2", "content": "content2",
"tags": [ "description": "description2",
"green" "tags": [
] "green"
} ]
""") }
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should not be null`() `And the response should not be null`()
`And have property`("$.versionId") `whish contains` "09c418b6-63ba-448b-b38b-502b41cd500e" `And have property`("$.versionId") `whish contains` "09c418b6-63ba-448b-b38b-502b41cd500e"

View File

@@ -1,16 +1,16 @@
package integration package integration
import integration.steps.`when`.Validate 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 GET request`
import integration.steps.`when`.`When I send a PUT request` import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body` 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 citizen`
import integration.steps.given.`authenticated as` 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.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK 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") `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") { `When I send a PUT request`("/citizens/0c966522-4071-43e5-a3ca-cfff2557f2cf/password/change") {
`authenticated as`("Georges", "Charpak") `authenticated as`("Georges", "Charpak")
`with body`(""" `with body`(
{ """
"oldPassword": "azerty", {
"newPassword": "qwerty" "oldPassword": "azerty",
} "newPassword": "qwerty"
""") }
"""
)
} `Then the response should be` Created } `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") `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) { `When I send a PUT request`("/citizens/6cf2a19d-d15d-4ee5-b2a9-907afd26b525/password/change", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Louis", "Breguet") `authenticated as`("Louis", "Breguet")
`with body`(""" `with body`(
{ """
"plup": "azerty", {
"gloup": "qwerty" "plup": "azerty",
} "gloup": "qwerty"
""") }
"""
)
} `Then the response should be` BadRequest } `Then the response should be` BadRequest
} }
} }

View File

@@ -1,18 +1,18 @@
package integration package integration
import fr.dcproject.component.citizen.database.CitizenI.Name 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 GET request`
import integration.steps.`when`.`When I send a POST 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`.`When I send a PUT request`
import integration.steps.`when`.`with body` 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 article`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article` import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as` 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.Created
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag 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") `Given I have article`(id = "aa16c635-28da-46f0-9a89-934eef88c7ca")
`When I send a POST request`("/articles/aa16c635-28da-46f0-9a89-934eef88c7ca/comments") { `When I send a POST request`("/articles/aa16c635-28da-46f0-9a89-934eef88c7ca/comments") {
`authenticated as`("Michael", "Faraday") `authenticated as`("Michael", "Faraday")
`with body`(""" `with body`(
{ """
"content": "Hello mister" {
} "content": "Hello mister"
""") }
"""
)
} `Then the response should be` Created and { } `Then the response should be` Created and {
`And the response should not be null`() `And the response should not be null`()
`And the response should contain`("$.target.id", "aa16c635-28da-46f0-9a89-934eef88c7ca") `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") `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") { `When I send a PUT request`("/comments/fd30d20f-656c-42c6-8955-f61c04537464") {
`authenticated as`("Hubert", "Reeves") `authenticated as`("Hubert", "Reeves")
`with body`(""" `with body`(
{ """
"content": "Hello boy" {
} "content": "Hello boy"
""") }
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should not be null`() `And the response should not be null`()
`And the response should contain`("$.content", "Hello boy") `And the response should contain`("$.content", "Hello boy")

View File

@@ -1,18 +1,18 @@
package integration package integration
import fr.dcproject.component.citizen.database.CitizenI.Name 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 GET request`
import integration.steps.`when`.`When I send a POST request` import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body` 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 citizen`
import integration.steps.given.`Given I have comment on constitution` import integration.steps.given.`Given I have comment on constitution`
import integration.steps.given.`Given I have constitution` import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as` 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.Created
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag 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") `Given I have constitution`(id = "1707c287-a472-4a62-89f2-9e85030e915c")
`When I send a POST request`("/constitutions/1707c287-a472-4a62-89f2-9e85030e915c/comments") { `When I send a POST request`("/constitutions/1707c287-a472-4a62-89f2-9e85030e915c/comments") {
`authenticated as`("Nicolas", "Copernic") `authenticated as`("Nicolas", "Copernic")
`with body`(""" `with body`(
{ """
"content": "Hello mister" {
} "content": "Hello mister"
""") }
"""
)
} `Then the response should be` Created and { } `Then the response should be` Created and {
`And the response should not be null`() `And the response should not be null`()
} }

View File

@@ -1,13 +1,13 @@
package integration 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.`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 article`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article` import integration.steps.given.`Given I have comment on article`
import integration.steps.given.`authenticated as` 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 io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags import org.junit.jupiter.api.Tags

View File

@@ -1,18 +1,18 @@
package integration package integration
import integration.steps.`when`.Validate 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 GET request`
import integration.steps.`when`.`When I send a POST request` import integration.steps.`when`.`When I send a POST request`
import integration.steps.`when`.`with body` 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 citizen`
import integration.steps.given.`Given I have constitution` import integration.steps.given.`Given I have constitution`
import integration.steps.given.`Given I have constitutions` import integration.steps.given.`Given I have constitutions`
import integration.steps.given.`authenticated as` 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.BadRequest
import io.ktor.http.HttpStatusCode.Companion.Created import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
@@ -66,18 +66,20 @@ class `Constitution routes` : BaseTest() {
`Given I have citizen`("Henri", "Poincaré") `Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions") { `When I send a POST request`("/constitutions") {
`authenticated as`("Henri", "Poincaré") `authenticated as`("Henri", "Poincaré")
`with body`(""" `with body`(
{ """
"versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e", {
"title":"Hello world!", "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
"anonymous":true, "title":"Hello world!",
"titles":[ "anonymous":true,
{ "titles":[
"name":"plop" {
} "name":"plop"
] }
} ]
""") }
"""
)
} `Then the response should be` Created and { } `Then the response should be` Created and {
`And the response should not be null`() `And the response should not be null`()
`And have property`("$.versionId") `whish contains` "15814bb6-8d90-4c6a-a456-c3939a8ec75e" `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é") `Given I have citizen`("Henri", "Poincaré")
`When I send a POST request`("/constitutions", Validate.ALL - Validate.REQUEST_BODY) { `When I send a POST request`("/constitutions", Validate.ALL - Validate.REQUEST_BODY) {
`authenticated as`("Henri", "Poincaré") `authenticated as`("Henri", "Poincaré")
`with body`(""" `with body`(
{ """
"versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e", {
"title":"Hello world!", "versionId":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
"anonymous":true, "title":"Hello world!",
"titles":[ "anonymous":true,
{ "titles":[
"name":"plop", {
"wrongField":0 "name":"plop",
} "wrongField":0
] }
} ]
""") }
"""
)
} `Then the response should be` BadRequest } `Then the response should be` BadRequest
} }
} }

View File

@@ -1,18 +1,18 @@
package integration 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 DELETE request`
import integration.steps.`when`.`When I send a GET 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 POST request`
import integration.steps.then.and
import integration.steps.given.`And follow article` import integration.steps.given.`And follow article`
import integration.steps.given.`Given I have article` import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as` import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content` 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.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK

View File

@@ -1,18 +1,18 @@
package integration 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 DELETE request`
import integration.steps.`when`.`When I send a GET 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 POST request`
import integration.steps.then.and
import integration.steps.given.`And follow constitution` import integration.steps.given.`And follow constitution`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have constitution` import integration.steps.given.`Given I have constitution`
import integration.steps.given.`authenticated as` import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content` 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.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK

View File

@@ -1,12 +1,12 @@
package integration 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`.`When I send a POST request`
import integration.steps.`when`.`with body` import integration.steps.`when`.`with body`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`authenticated as` 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 integration.steps.then.and
import io.ktor.http.HttpStatusCode.Companion.NoContent import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
@@ -23,15 +23,17 @@ class `Login routes` : BaseTest() {
withIntegrationApplication { withIntegrationApplication {
`Given I have citizen`("Niels", "Bohr") `Given I have citizen`("Niels", "Bohr")
`When I send a POST request`("/login") { `When I send a POST request`("/login") {
`with body`(""" `with body`(
{ """
"username": "niels-bohr", {
"password": "azerty" "username": "niels-bohr",
} "password": "azerty"
""") }
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should not be null`() `and should contains` "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9." `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") `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") { `When I send a POST request`("/auth/passwordless") {
`authenticated as`("Leonhard", "Euler") `authenticated as`("Leonhard", "Euler")
`with body`(""" `with body`(
{ """
"url": "https://dc-project.fr/password/reset", {
"email": "fabrice.lecomte.be@gmail.com" "url": "https://dc-project.fr/password/reset",
} "email": "fabrice.lecomte.be@gmail.com"
""") }
"""
)
} `Then the response should be` NoContent } `Then the response should be` NoContent
} }
} }

View File

@@ -1,18 +1,18 @@
package integration package integration
import fr.dcproject.component.citizen.database.CitizenI.Name 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 GET request`
import integration.steps.`when`.`When I send a PUT request` import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body` 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 an opinion choice`
import integration.steps.given.`Given I have article` import integration.steps.given.`Given I have article`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have opinion on article` import integration.steps.given.`Given I have opinion on article`
import integration.steps.given.`authenticated as` 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.Created
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag 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")) `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") { `When I send a PUT request`("/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/opinions") {
`authenticated as`("Isaac", "Newton") `authenticated as`("Isaac", "Newton")
`with body`(""" `with body`(
{ """
"ids": [ {
"0f4f1721-3136-44f1-9f31-1459f3317b15" "ids": [
] "0f4f1721-3136-44f1-9f31-1459f3317b15"
} ]
""") }
"""
)
} `Then the response should be` Created } `Then the response should be` Created
} }
} }

View File

@@ -22,17 +22,19 @@ class `Register routes` : BaseTest() {
fun `I can register`() { fun `I can register`() {
withIntegrationApplication { withIntegrationApplication {
`When I send a POST request`("/register") { `When I send a POST request`("/register") {
`with body`(""" `with body`(
{ """
"name": {"firstName":"George", "lastName":"MICHEL"}, {
"birthday": "2001-01-01", "name": {"firstName":"George", "lastName":"MICHEL"},
"user":{ "birthday": "2001-01-01",
"username": "george-junior", "user":{
"password": "azerty" "username": "george-junior",
}, "password": "azerty"
"email": "george-junior@gmail.com" },
} "email": "george-junior@gmail.com"
""") }
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should not be null`() `And the response should not be null`()
`And the response should contain pattern`("$.token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.") `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`() { fun `I cannot register if no username was sent`() {
withIntegrationApplication { withIntegrationApplication {
`When I send a POST request`("/register", Validate.ALL - Validate.REQUEST_BODY) { `When I send a POST request`("/register", Validate.ALL - Validate.REQUEST_BODY) {
`with body`(""" `with body`(
{ """
"name": {"firstName":"George2", "lastName":"MICHEL2"}, {
"birthday": "2001-01-01", "name": {"firstName":"George2", "lastName":"MICHEL2"},
"user":{ "birthday": "2001-01-01",
"password": "" "user":{
}, "password": ""
"email": "george-junior@gmail.com" },
} "email": "george-junior@gmail.com"
""") }
"""
)
} `Then the response should be` BadRequest and { } `Then the response should be` BadRequest and {
`And the response should be null`() `And the response should be null`()
} }

View File

@@ -1,12 +1,9 @@
package integration package integration
import fr.dcproject.component.citizen.database.CitizenI.Name 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 GET request`
import integration.steps.`when`.`When I send a PUT request` import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body` 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 article`
import integration.steps.given.`Given I have citizen` import integration.steps.given.`Given I have citizen`
import integration.steps.given.`Given I have comment on article` 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.`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.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.Created
import io.ktor.http.HttpStatusCode.Companion.OK import io.ktor.http.HttpStatusCode.Companion.OK
import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Tag
@@ -31,11 +31,13 @@ class `Vote routes` : BaseTest() {
`Given I have article`(id = "835c5101-ca39-4038-a4e6-da6ee62ca6d5") `Given I have article`(id = "835c5101-ca39-4038-a4e6-da6ee62ca6d5")
`When I send a PUT request`("/articles/835c5101-ca39-4038-a4e6-da6ee62ca6d5/vote") { `When I send a PUT request`("/articles/835c5101-ca39-4038-a4e6-da6ee62ca6d5/vote") {
`authenticated as`("Thalès", "Milet") `authenticated as`("Thalès", "Milet")
`with body`(""" `with body`(
{ """
"note": 1 {
} "note": 1
""") }
"""
)
} `Then the response should be` Created } `Then the response should be` Created
} }
} }
@@ -47,11 +49,13 @@ class `Vote routes` : BaseTest() {
`Given I have constitution`(id = "76e79c89-efc1-492d-9e8f-dc9717363a11") `Given I have constitution`(id = "76e79c89-efc1-492d-9e8f-dc9717363a11")
`When I send a PUT request`("/constitutions/76e79c89-efc1-492d-9e8f-dc9717363a11/vote") { `When I send a PUT request`("/constitutions/76e79c89-efc1-492d-9e8f-dc9717363a11/vote") {
`authenticated as`("Gregor", "Mendel") `authenticated as`("Gregor", "Mendel")
`with body`(""" `with body`(
{ """
"note": 1 {
} "note": 1
""") }
"""
)
} `Then the response should be` Created } `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") { `When I send a PUT request`("/comments/e793eccc-456b-4450-a292-46d592229b74/vote") {
`authenticated as`("Antoine", "Lavoisier") `authenticated as`("Antoine", "Lavoisier")
`with body`(""" `with body`(
{ """
"note": -1 {
} "note": -1
""") }
"""
)
} `Then the response should be` Created and { } `Then the response should be` Created and {
`And the response should contain`("$.down", 1) `And the response should contain`("$.down", 1)
} }

View File

@@ -1,22 +1,22 @@
package integration package integration
import fr.dcproject.component.citizen.database.CitizenI.Name 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 DELETE request`
import integration.steps.`when`.`When I send a GET 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 POST request`
import integration.steps.`when`.`When I send a PUT request` import integration.steps.`when`.`When I send a PUT request`
import integration.steps.`when`.`with body` 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 citizen`
import integration.steps.given.`Given I have workgroup` import integration.steps.given.`Given I have workgroup`
import integration.steps.given.`With members` import integration.steps.given.`With members`
import integration.steps.given.`authenticated as` import integration.steps.given.`authenticated as`
import integration.steps.given.`with no content` import integration.steps.given.`with no content`
import integration.steps.then.`And have property` import integration.steps.then.`And have property`
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 io.ktor.http.HttpStatusCode.Companion.Created import io.ktor.http.HttpStatusCode.Companion.Created
import io.ktor.http.HttpStatusCode.Companion.NoContent import io.ktor.http.HttpStatusCode.Companion.NoContent
import io.ktor.http.HttpStatusCode.Companion.NotFound import io.ktor.http.HttpStatusCode.Companion.NotFound
@@ -68,14 +68,16 @@ class `Workgroup routes` : BaseTest() {
`Given I have citizen`("Werner", "Heisenberg") `Given I have citizen`("Werner", "Heisenberg")
`When I send a POST request`("/workgroups") { `When I send a POST request`("/workgroups") {
`authenticated as`("Werner", "Heisenberg") `authenticated as`("Werner", "Heisenberg")
`with body`(""" `with body`(
{ """
"id":"f496d86d-6654-4068-91ff-90e1dbcc5f38", {
"name":"Les Bouffons", "id":"f496d86d-6654-4068-91ff-90e1dbcc5f38",
"description":"La vie est belle", "name":"Les Bouffons",
"anonymous":false "description":"La vie est belle",
} "anonymous":false
""") }
"""
)
} `Then the response should be` Created and { } `Then the response should be` Created and {
`And the response should contain`("$.id", "f496d86d-6654-4068-91ff-90e1dbcc5f38") `And the response should contain`("$.id", "f496d86d-6654-4068-91ff-90e1dbcc5f38")
`And the response should contain`("$.name", "Les Bouffons") `And the response should contain`("$.name", "Les Bouffons")
@@ -103,12 +105,14 @@ class `Workgroup routes` : BaseTest() {
} }
`When I send a PUT request`("/workgroups/aa875a24-0050-4252-9130-d37391714e26") { `When I send a PUT request`("/workgroups/aa875a24-0050-4252-9130-d37391714e26") {
`authenticated as`("John", "Wheeler") `authenticated as`("John", "Wheeler")
`with body`(""" `with body`(
{ """
"name":"La ratatouille", {
"description":"Une petite souris" "name":"La ratatouille",
} "description":"Une petite souris"
""") }
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should contain`("$.id", "aa875a24-0050-4252-9130-d37391714e26") `And the response should contain`("$.id", "aa875a24-0050-4252-9130-d37391714e26")
`And the response should contain`("$.name", "La ratatouille") `And the response should contain`("$.name", "La ratatouille")
@@ -171,18 +175,20 @@ class `Workgroup routes` : BaseTest() {
`Given I have workgroup`("b0ea1922-3bc6-44e2-aa7c-40158998cfbb", createdBy = Name("Blaise", "Pascal")) `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") { `When I send a POST request`("/workgroups/b0ea1922-3bc6-44e2-aa7c-40158998cfbb/members") {
`authenticated as`("Blaise", "Pascal") `authenticated as`("Blaise", "Pascal")
`with body`(""" `with body`(
[ """
{ [
"citizen": {"id":"6d883fe7-5fc0-4a50-8858-72230673eba4"}, {
"roles": ["MASTER"] "citizen": {"id":"6d883fe7-5fc0-4a50-8858-72230673eba4"},
}, "roles": ["MASTER"]
{ },
"citizen": {"id":"b5bac515-45d4-4aeb-9b6d-2627a0bbc419"}, {
"roles": ["MASTER"] "citizen": {"id":"b5bac515-45d4-4aeb-9b6d-2627a0bbc419"},
} "roles": ["MASTER"]
] }
""") ]
"""
)
} `Then the response should be` Created } `Then the response should be` Created
} }
} }
@@ -231,18 +237,20 @@ class `Workgroup routes` : BaseTest() {
} }
`When I send a PUT request`("/workgroups/784fe6bc-7635-4ae2-b080-3a4743b998bf/members") { `When I send a PUT request`("/workgroups/784fe6bc-7635-4ae2-b080-3a4743b998bf/members") {
`authenticated as`("Leon", "Foucault") `authenticated as`("Leon", "Foucault")
`with body`(""" `with body`(
[ """
{ [
"citizen": {"id":"be3b0926-8628-4426-804a-75188a6eb315"}, {
"roles": ["MASTER"] "citizen": {"id":"be3b0926-8628-4426-804a-75188a6eb315"},
}, "roles": ["MASTER"]
{ },
"citizen": {"id":"b49e20c1-8393-45d6-a6a0-3fa5c71cbdc1"}, {
"roles": ["MASTER"] "citizen": {"id":"b49e20c1-8393-45d6-a6a0-3fa5c71cbdc1"},
} "roles": ["MASTER"]
] }
""") ]
"""
)
} `Then the response should be` OK and { } `Then the response should be` OK and {
`And the response should contain list`("$", 2, 2) `And the response should contain list`("$", 2, 2)
`And the response should contain`("$.[0]citizen.id", "be3b0926-8628-4426-804a-75188a6eb315") `And the response should contain`("$.[0]citizen.id", "be3b0926-8628-4426-804a-75188a6eb315")

View File

@@ -33,7 +33,7 @@ fun Schema.validate(api: OpenApi3, toValidate: JsonNode) {
} }
fun TestApplicationResponse.operation(route: String? = null, callback: Operation.(OpenApi3, String) -> Unit): Operation { fun TestApplicationResponse.operation(route: String? = null, callback: Operation.(OpenApi3, String) -> Unit): Operation {
val filePath = "/openapi2.yaml" val filePath = "/openapi.yaml"
return OpenApi3Parser().parse(File(filePath.getResource().toURI()), true).let { api: OpenApi3 -> return OpenApi3Parser().parse(File(filePath.getResource().toURI()), true).let { api: OpenApi3 ->
val httpMethod = call.request.httpMethod val httpMethod = call.request.httpMethod
val uri = route ?: "/" + Url(call.request.uri).encodedPath val uri = route ?: "/" + Url(call.request.uri).encodedPath

View File

@@ -11,6 +11,7 @@ import fr.dcproject.component.citizen.database.CitizenCreator
import fr.dcproject.component.citizen.database.CitizenI import fr.dcproject.component.citizen.database.CitizenI
import fr.dcproject.component.vote.VoteAccessControl import fr.dcproject.component.vote.VoteAccessControl
import fr.dcproject.component.vote.database.VoteForUpdate import fr.dcproject.component.vote.database.VoteForUpdate
import fr.dcproject.component.vote.database.VoteForView
import org.amshove.kluent.`should be` import org.amshove.kluent.`should be`
import org.joda.time.DateTime import org.joda.time.DateTime
import org.junit.jupiter.api.Tag 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.Execution
import org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT import org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT
import java.util.UUID import java.util.UUID
import fr.dcproject.component.vote.database.VoteForView
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(CONCURRENT) @Execution(CONCURRENT)