remove fixed raw citizen and use real current citizen
Fix tests
This commit is contained in:
@@ -1,26 +1,16 @@
|
|||||||
package fr.dcproject.routes
|
package fr.dcproject.routes
|
||||||
|
|
||||||
|
import fr.dcproject.citizen
|
||||||
import fr.dcproject.entity.Citizen
|
import fr.dcproject.entity.Citizen
|
||||||
import fr.dcproject.entity.User
|
|
||||||
import io.ktor.application.call
|
import io.ktor.application.call
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.locations.*
|
import io.ktor.locations.*
|
||||||
import io.ktor.response.respond
|
import io.ktor.response.respond
|
||||||
import io.ktor.routing.Route
|
import io.ktor.routing.Route
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.*
|
|
||||||
import fr.dcproject.entity.Article as ArticleEntity
|
import fr.dcproject.entity.Article as ArticleEntity
|
||||||
import fr.dcproject.entity.Follow as FollowEntity
|
import fr.dcproject.entity.Follow as FollowEntity
|
||||||
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
||||||
|
|
||||||
// TODO get current citizen
|
|
||||||
val currentCitizen = Citizen(
|
|
||||||
id = UUID.fromString("64b7b379-2298-43ec-b428-ba134930cabd"),
|
|
||||||
name = Citizen.Name("todo", "todo"),
|
|
||||||
birthday = DateTime.now(),
|
|
||||||
user = User(username = "plop", plainPassword = "plip")
|
|
||||||
)
|
|
||||||
|
|
||||||
@KtorExperimentalLocationsAPI
|
@KtorExperimentalLocationsAPI
|
||||||
object FollowArticlePaths {
|
object FollowArticlePaths {
|
||||||
@Location("/articles/{article}/follow") class ArticleFollowRequest(val article: ArticleEntity)
|
@Location("/articles/{article}/follow") class ArticleFollowRequest(val article: ArticleEntity)
|
||||||
@@ -30,12 +20,12 @@ object FollowArticlePaths {
|
|||||||
@KtorExperimentalLocationsAPI
|
@KtorExperimentalLocationsAPI
|
||||||
fun Route.followArticle(repo: FollowArticleRepository) {
|
fun Route.followArticle(repo: FollowArticleRepository) {
|
||||||
post<FollowArticlePaths.ArticleFollowRequest> {
|
post<FollowArticlePaths.ArticleFollowRequest> {
|
||||||
repo.follow(FollowEntity(target = it.article, createdBy = currentCitizen))
|
repo.follow(FollowEntity(target = it.article, createdBy = this.citizen))
|
||||||
call.respond(HttpStatusCode.Created)
|
call.respond(HttpStatusCode.Created)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete<FollowArticlePaths.ArticleFollowRequest> {
|
delete<FollowArticlePaths.ArticleFollowRequest> {
|
||||||
repo.unfollow(FollowEntity(target = it.article, createdBy = currentCitizen))
|
repo.unfollow(FollowEntity(target = it.article, createdBy = this.citizen))
|
||||||
call.respond(HttpStatusCode.NoContent)
|
call.respond(HttpStatusCode.NoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,16 @@
|
|||||||
package fr.dcproject.routes
|
package fr.dcproject.routes
|
||||||
|
|
||||||
|
import fr.dcproject.citizen
|
||||||
import fr.dcproject.entity.Citizen
|
import fr.dcproject.entity.Citizen
|
||||||
import fr.dcproject.entity.User
|
|
||||||
import io.ktor.application.call
|
import io.ktor.application.call
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.locations.*
|
import io.ktor.locations.*
|
||||||
import io.ktor.response.respond
|
import io.ktor.response.respond
|
||||||
import io.ktor.routing.Route
|
import io.ktor.routing.Route
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.*
|
|
||||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||||
import fr.dcproject.entity.Follow as FollowEntity
|
import fr.dcproject.entity.Follow as FollowEntity
|
||||||
import fr.dcproject.repository.FollowConstitution as FollowConstitutionRepository
|
import fr.dcproject.repository.FollowConstitution as FollowConstitutionRepository
|
||||||
|
|
||||||
// TODO get current citizen
|
|
||||||
val currentCitizen2 = Citizen(
|
|
||||||
id = UUID.fromString("64b7b379-2298-43ec-b428-ba134930cabd"),
|
|
||||||
name = Citizen.Name("todo", "todo"),
|
|
||||||
birthday = DateTime.now(),
|
|
||||||
user = User(username = "plop", plainPassword = "plip")
|
|
||||||
)
|
|
||||||
|
|
||||||
@KtorExperimentalLocationsAPI
|
@KtorExperimentalLocationsAPI
|
||||||
object FollowConstitutionPaths {
|
object FollowConstitutionPaths {
|
||||||
@Location("/constitutions/{constitution}/follow") class ConstitutionFollowRequest(val constitution: ConstitutionEntity)
|
@Location("/constitutions/{constitution}/follow") class ConstitutionFollowRequest(val constitution: ConstitutionEntity)
|
||||||
@@ -30,12 +20,12 @@ object FollowConstitutionPaths {
|
|||||||
@KtorExperimentalLocationsAPI
|
@KtorExperimentalLocationsAPI
|
||||||
fun Route.followConstitution(repo: FollowConstitutionRepository) {
|
fun Route.followConstitution(repo: FollowConstitutionRepository) {
|
||||||
post<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
post<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
||||||
repo.follow(FollowEntity(target = it.constitution, createdBy = currentCitizen2))
|
repo.follow(FollowEntity(target = it.constitution, createdBy = this.citizen))
|
||||||
call.respond(HttpStatusCode.Created)
|
call.respond(HttpStatusCode.Created)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
delete<FollowConstitutionPaths.ConstitutionFollowRequest> {
|
||||||
repo.unfollow(FollowEntity(target = it.constitution, createdBy = currentCitizen2))
|
repo.unfollow(FollowEntity(target = it.constitution, createdBy = this.citizen))
|
||||||
call.respond(HttpStatusCode.NoContent)
|
call.respond(HttpStatusCode.NoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Feature: Auth routes
|
|||||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
|
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: The route for create citizen must response a 200 and return object
|
Scenario: The route for create citizen must response a 400 and return object
|
||||||
When I send a POST request to "/register" with body:
|
When I send a POST request to "/register" with body:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
Feature: citizens routes
|
Feature: citizens routes
|
||||||
|
|
||||||
Scenario: The route for get citizens must response a 200
|
Scenario: The route for get citizens must response a 200
|
||||||
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a GET request to "/citizens"
|
When I send a GET request to "/citizens"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
|
|
||||||
Scenario: The route for get one citizen must response a 200 and return citizen
|
Scenario: The route for get one citizen must response a 200 and return citizen
|
||||||
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a GET request to "/citizens/6434f4f9-f570-f22a-c134-8668350651ff"
|
When I send a GET request to "/citizens/6434f4f9-f570-f22a-c134-8668350651ff"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response should contain object:
|
And the response should contain object:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Feature: constitution routes
|
|||||||
| id | 0ca489a6-ef68-8bd5-2355-5793d4b3d66c |
|
| id | 0ca489a6-ef68-8bd5-2355-5793d4b3d66c |
|
||||||
|
|
||||||
Scenario: The route for create constitution must response a 200 and return object
|
Scenario: The route for create constitution must response a 200 and return object
|
||||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a POST request to "/constitutions" with body:
|
When I send a POST request to "/constitutions" with body:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Feature: follow Article and Constitution
|
|||||||
|
|
||||||
# Article
|
# Article
|
||||||
Scenario: The route for follow article must response a 201 and return object
|
Scenario: The route for follow article must response a 201 and return object
|
||||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a POST request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow"
|
When I send a POST request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow"
|
||||||
Then the response status code should be 201
|
Then the response status code should be 201
|
||||||
|
|
||||||
@@ -15,13 +15,13 @@ Feature: follow Article and Constitution
|
|||||||
| limit | 50 |
|
| limit | 50 |
|
||||||
|
|
||||||
Scenario: The route for unfollow article must response a 204
|
Scenario: The route for unfollow article must response a 204
|
||||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a DELETE request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow"
|
When I send a DELETE request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow"
|
||||||
Then the response status code should be 204
|
Then the response status code should be 204
|
||||||
|
|
||||||
# Constitution
|
# Constitution
|
||||||
Scenario: The route for follow constitution must response a 201 and return object
|
Scenario: The route for follow constitution must response a 201 and return object
|
||||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a POST request to "/constitutions/72aa1ee1-4963-eb44-c9e0-5ce6e0f18f00/follow"
|
When I send a POST request to "/constitutions/72aa1ee1-4963-eb44-c9e0-5ce6e0f18f00/follow"
|
||||||
Then the response status code should be 201
|
Then the response status code should be 201
|
||||||
|
|
||||||
@@ -34,6 +34,6 @@ Feature: follow Article and Constitution
|
|||||||
| limit | 50 |
|
| limit | 50 |
|
||||||
|
|
||||||
Scenario: The route for unfollow constitution must response a 204
|
Scenario: The route for unfollow constitution must response a 204
|
||||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||||
When I send a DELETE request to "/constitutions/72aa1ee1-4963-eb44-c9e0-5ce6e0f18f00/follow"
|
When I send a DELETE request to "/constitutions/72aa1ee1-4963-eb44-c9e0-5ce6e0f18f00/follow"
|
||||||
Then the response status code should be 204
|
Then the response status code should be 204
|
||||||
|
|||||||
Reference in New Issue
Block a user