Can vote on Comment
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package feature
|
||||
|
||||
import fr.dcproject.entity.Citizen
|
||||
import fr.dcproject.repository.CommentArticle
|
||||
import io.cucumber.java8.En
|
||||
import org.joda.time.DateTime
|
||||
import org.koin.test.KoinTest
|
||||
@@ -8,6 +9,7 @@ import org.koin.test.get
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletionException
|
||||
import fr.dcproject.entity.Article as ArticleEntity
|
||||
import fr.dcproject.entity.Comment as CommentEntity
|
||||
import fr.dcproject.entity.User as UserEntity
|
||||
import fr.dcproject.repository.Article as ArticleRepository
|
||||
import fr.dcproject.repository.Citizen as CitizenRepository
|
||||
@@ -49,5 +51,36 @@ class ArticleSteps: En, KoinTest {
|
||||
)
|
||||
get<ArticleRepository>().upsert(article)
|
||||
}
|
||||
|
||||
Given("I have comment {string} on article {string}") { commentId: String, articleId: 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 article = ArticleEntity(
|
||||
id = UUID.fromString(articleId),
|
||||
title = "hello",
|
||||
content = "bla bla bla",
|
||||
description = "A super article",
|
||||
createdBy = citizen
|
||||
)
|
||||
get<ArticleRepository>().upsert(article)
|
||||
|
||||
val comment = CommentEntity(
|
||||
id = UUID.fromString(commentId),
|
||||
createdBy = citizen,
|
||||
target = article,
|
||||
content = "hello"
|
||||
)
|
||||
get<CommentArticle>().comment(comment)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user