Implement comment constitution
fix bugs
This commit is contained in:
62
src/test/kotlin/feature/ConstitutionSteps.kt
Normal file
62
src/test/kotlin/feature/ConstitutionSteps.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
package feature
|
||||
|
||||
import fr.dcproject.entity.Citizen
|
||||
import io.cucumber.java8.En
|
||||
import org.joda.time.DateTime
|
||||
import org.koin.test.KoinTest
|
||||
import org.koin.test.get
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletionException
|
||||
import fr.dcproject.entity.Constitution as ConstitutionEntity
|
||||
import fr.dcproject.entity.Constitution.Title as TitleEntity
|
||||
import fr.dcproject.entity.User as UserEntity
|
||||
import fr.dcproject.repository.Citizen as CitizenRepository
|
||||
import fr.dcproject.repository.Constitution as ConstitutionRepository
|
||||
|
||||
class ConstitutionSteps: En, KoinTest {
|
||||
init {
|
||||
Given("I have constitution with id {string}") { id: String ->
|
||||
var citizen = Citizen(
|
||||
name = Citizen.Name("John", "Doe"),
|
||||
birthday = DateTime.now(),
|
||||
user = UserEntity(username = "john-doe", plainPassword = "azerty")
|
||||
)
|
||||
|
||||
try {
|
||||
get<CitizenRepository>().insertWithUser(citizen)
|
||||
} catch (e: CompletionException) {
|
||||
citizen = get<CitizenRepository>().findByUsername("john-doe")!!
|
||||
}
|
||||
|
||||
val title1 = TitleEntity(
|
||||
name = "My Title"
|
||||
)
|
||||
|
||||
val constitution = ConstitutionEntity(
|
||||
id = UUID.fromString(id),
|
||||
title = "hello",
|
||||
titles = listOf(title1),
|
||||
createdBy = citizen,
|
||||
annonymous = false
|
||||
)
|
||||
get<ConstitutionRepository>().upsert(constitution)
|
||||
}
|
||||
|
||||
Given("I have constitution with id {string} created by {string}") { id: String, username: String ->
|
||||
val citizen = get<CitizenRepository>().findByUsername(username)!!
|
||||
|
||||
val title1 = TitleEntity(
|
||||
name = "My Title"
|
||||
)
|
||||
|
||||
val constitution = ConstitutionEntity(
|
||||
id = UUID.fromString(id),
|
||||
title = "hello",
|
||||
titles = listOf(title1),
|
||||
createdBy = citizen,
|
||||
annonymous = false
|
||||
)
|
||||
get<ConstitutionRepository>().upsert(constitution)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
Feature: comment Article and Constitution
|
||||
Feature: comment Article
|
||||
|
||||
# Article
|
||||
Scenario: The route for comment article must response a 201 and return object
|
||||
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
And I have article with id "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b"
|
||||
@@ -34,7 +33,3 @@ Feature: comment Article and Constitution
|
||||
Then the response status code should be 200
|
||||
And the JSON should contain:
|
||||
| content | Hello boy |
|
||||
|
||||
|
||||
# Constitution
|
||||
# TODO
|
||||
35
src/test/resources/feature/commentConstitution.feature
Normal file
35
src/test/resources/feature/commentConstitution.feature
Normal file
@@ -0,0 +1,35 @@
|
||||
Feature: comment Constitution
|
||||
|
||||
Scenario: The route for comment constitution must response a 201 and return object
|
||||
Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
And I have constitution with id "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b"
|
||||
When I send a POST request to "/constitutions/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/comments" with body:
|
||||
"""
|
||||
Hello mister
|
||||
"""
|
||||
Then the response status code should be 201
|
||||
|
||||
Scenario: The route for get comments of constitutions for the current citizen must response a 200 and return objects
|
||||
Given I have citizen John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
And I have constitution with id "9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b"
|
||||
When I send a GET request to "/citizens/64b7b379-2298-43ec-b428-ba134930cabd/comments/constitutions"
|
||||
Then the response status code should be 200
|
||||
And the response should contain object:
|
||||
| current_page | 1 |
|
||||
| limit | 50 |
|
||||
|
||||
Scenario: The route for edit comment must response a 200 and return object
|
||||
Given I am authenticated as username 3 with id "92877af7-0a45-fd6a-2ed7-fe81e1236b78"
|
||||
When I send a PUT request to "/comments/b0422e48-687f-bea7-b45f-b6b301246e97" with body:
|
||||
"""
|
||||
Hello boy
|
||||
"""
|
||||
Then the response status code should be 200
|
||||
And the JSON should contain:
|
||||
| content | Hello boy |
|
||||
|
||||
Scenario: The route for get comment must response a 200 and return object
|
||||
When I send a GET request to "/comments/b0422e48-687f-bea7-b45f-b6b301246e97"
|
||||
Then the response status code should be 200
|
||||
And the JSON should contain:
|
||||
| content | Hello boy |
|
||||
Reference in New Issue
Block a user