Lint
This commit is contained in:
@@ -17,7 +17,6 @@ import kotlinx.coroutines.runBlocking
|
|||||||
import kotlinx.io.errors.IOException
|
import kotlinx.io.errors.IOException
|
||||||
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
||||||
|
|
||||||
|
|
||||||
class ArticleUpdate(
|
class ArticleUpdate(
|
||||||
target: Article
|
target: Article
|
||||||
) : EntityEvent(target, "article", "update") {
|
) : EntityEvent(target, "article", "update") {
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ class Publisher(
|
|||||||
) {
|
) {
|
||||||
fun <T : EntityEvent> publish(it: T): Job {
|
fun <T : EntityEvent> publish(it: T): Job {
|
||||||
return GlobalScope.launch {
|
return GlobalScope.launch {
|
||||||
factory.newConnection().use { connection -> connection.createChannel().use { channel ->
|
factory.newConnection().use { connection ->
|
||||||
|
connection.createChannel().use { channel ->
|
||||||
channel.basicPublish(config.exchangeNotificationName, "", null, it.serialize().toByteArray())
|
channel.basicPublish(config.exchangeNotificationName, "", null, it.serialize().toByteArray())
|
||||||
logger.debug("Publish message ${it.target.id}")
|
logger.debug("Publish message ${it.target.id}")
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ class FollowArticle(requester: Requester) : Follow<ArticleRef, ArticleEntity>(re
|
|||||||
): Paginated<FollowSimple<ArticleRef, CitizenRef>> {
|
): Paginated<FollowSimple<ArticleRef, CitizenRef>> {
|
||||||
return requester
|
return requester
|
||||||
.getFunction("find_follows_article_by_target")
|
.getFunction("find_follows_article_by_target")
|
||||||
.select(page, limit,
|
.select(
|
||||||
|
page, limit,
|
||||||
"target_id" to target.id
|
"target_id" to target.id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ class ArticleSteps : En, KoinTest {
|
|||||||
|
|
||||||
Given("I have article") { extraData: DataTable ->
|
Given("I have article") { extraData: DataTable ->
|
||||||
extraData.asMap<String, String>(String::class.java, String::class.java).let { params ->
|
extraData.asMap<String, String>(String::class.java, String::class.java).let { params ->
|
||||||
val username = params["createdBy"]?.toLowerCase()?.replace(' ', '-') ?: error("You must provide the 'createdBy' parameter")
|
val username = params["createdBy"]?.toLowerCase()?.replace(' ', '-')
|
||||||
|
?: error("You must provide the 'createdBy' parameter")
|
||||||
val citizen = get<CitizenRepository>().findByUsername(username) ?: error("Citizen not exist")
|
val citizen = get<CitizenRepository>().findByUsername(username) ?: error("Citizen not exist")
|
||||||
val id = params["id"]?.toUUID() ?: UUID.randomUUID()
|
val id = params["id"]?.toUUID() ?: UUID.randomUUID()
|
||||||
val article = ArticleEntity(
|
val article = ArticleEntity(
|
||||||
@@ -59,7 +60,6 @@ class ArticleSteps : En, KoinTest {
|
|||||||
)
|
)
|
||||||
get<ArticleRepository>().upsert(article)
|
get<ArticleRepository>().upsert(article)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Given("I have article with id {string} created by {string}") { id: String, username: String ->
|
Given("I have article with id {string} created by {string}") { id: String, username: String ->
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import fr.dcproject.repository.Citizen as CitizenRepository
|
|||||||
import fr.dcproject.repository.OpinionArticle as OpinionRepository
|
import fr.dcproject.repository.OpinionArticle as OpinionRepository
|
||||||
import fr.dcproject.repository.OpinionChoice as OpinionChoiceRepository
|
import fr.dcproject.repository.OpinionChoice as OpinionChoiceRepository
|
||||||
|
|
||||||
|
|
||||||
class OpinionSteps : En, KoinTest {
|
class OpinionSteps : En, KoinTest {
|
||||||
init {
|
init {
|
||||||
Given("I have the opinion {string} on article {string} created by {string}:") { opinionChoice: String, article: String, citizen: String, extraInfo: DataTable ->
|
Given("I have the opinion {string} on article {string} created by {string}:") { opinionChoice: String, article: String, citizen: String, extraInfo: DataTable ->
|
||||||
extraInfo.asMap<String, String>(String::class.java, String::class.java).let {
|
extraInfo.asMap<String, String>(String::class.java, String::class.java).let {
|
||||||
val opinion = OpinionArticle(
|
val opinion = OpinionArticle(
|
||||||
choice = get<OpinionChoiceRepository>().findOpinionsChoiceByName(opinionChoice) ?: error("Opinion Choice not exist"),
|
choice = get<OpinionChoiceRepository>().findOpinionsChoiceByName(opinionChoice)
|
||||||
|
?: error("Opinion Choice not exist"),
|
||||||
target = get<ArticleRepository>().findById(article.toUUID()) ?: error("Article not exist"),
|
target = get<ArticleRepository>().findById(article.toUUID()) ?: error("Article not exist"),
|
||||||
createdBy = get<CitizenRepository>().findById(citizen.toUUID()) ?: error("Citizen not exist")
|
createdBy = get<CitizenRepository>().findById(citizen.toUUID()) ?: error("Citizen not exist")
|
||||||
)
|
)
|
||||||
@@ -27,10 +27,15 @@ class OpinionSteps : En, KoinTest {
|
|||||||
|
|
||||||
Given("I have an opinion") { extraInfo: DataTable ->
|
Given("I have an opinion") { extraInfo: DataTable ->
|
||||||
extraInfo.asMap<String, String>(String::class.java, String::class.java)?.let { params ->
|
extraInfo.asMap<String, String>(String::class.java, String::class.java)?.let { params ->
|
||||||
val username = params["createdBy"]?.toLowerCase()?.replace(' ', '-') ?: error("You must provide the 'createdBy' parameter")
|
val username = params["createdBy"]?.toLowerCase()?.replace(' ', '-')
|
||||||
|
?: error("You must provide the 'createdBy' parameter")
|
||||||
val opinion = OpinionArticle(
|
val opinion = OpinionArticle(
|
||||||
choice = params["opinion"]?.let { get<OpinionChoiceRepository>().findOpinionsChoiceByName(it) ?: error("Opinion Choice not exist")} ?: error("You must provide the 'opinion' parameter"),
|
choice = params["opinion"]?.let {
|
||||||
target = params["article"]?.let { get<ArticleRepository>().findById(it.toUUID()) ?: error("Article not exist")} ?: error("You must provide the 'article' parameter"),
|
get<OpinionChoiceRepository>().findOpinionsChoiceByName(it) ?: error("Opinion Choice not exist")
|
||||||
|
} ?: error("You must provide the 'opinion' parameter"),
|
||||||
|
target = params["article"]?.let {
|
||||||
|
get<ArticleRepository>().findById(it.toUUID()) ?: error("Article not exist")
|
||||||
|
} ?: error("You must provide the 'article' parameter"),
|
||||||
createdBy = get<CitizenRepository>().findByUsername(username) ?: error("Citizen not exist")
|
createdBy = get<CitizenRepository>().findByUsername(username) ?: error("Citizen not exist")
|
||||||
)
|
)
|
||||||
get<OpinionRepository>().opinion(opinion)
|
get<OpinionRepository>().opinion(opinion)
|
||||||
|
|||||||
Reference in New Issue
Block a user