Implement comment constitution

fix bugs
This commit is contained in:
2019-08-28 23:32:43 +02:00
parent 33f4992b5e
commit 4c2da6ab71
17 changed files with 277 additions and 86 deletions

View 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)
}
}
}