Lint
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.*
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSubclassOf
|
||||
|
||||
interface ExtraI<T : TargetI, C: CitizenI> :
|
||||
interface ExtraI<T : TargetI, C : CitizenI> :
|
||||
UuidEntityI,
|
||||
EntityCreatedAt,
|
||||
EntityCreatedBy<C> {
|
||||
|
||||
@@ -10,7 +10,7 @@ class Follow<T : TargetI>(
|
||||
) : ExtraI<T, CitizenBasicI>,
|
||||
FollowSimple<T, CitizenBasicI>(id, createdBy, target)
|
||||
|
||||
open class FollowSimple<T : TargetI, C: CitizenI>(
|
||||
open class FollowSimple<T : TargetI, C : CitizenI>(
|
||||
id: UUID = UUID.randomUUID(),
|
||||
override val createdBy: C,
|
||||
override var target: T
|
||||
|
||||
@@ -11,7 +11,7 @@ open class Opinion<T : TargetI>(
|
||||
override val createdBy: CitizenBasic,
|
||||
override val target: T,
|
||||
val choice: OpinionChoice
|
||||
) : ExtraI<T,CitizenBasicI>,
|
||||
) : ExtraI<T, CitizenBasicI>,
|
||||
TargetRef(id),
|
||||
EntityCreatedAt by EntityCreatedAtImp(),
|
||||
EntityCreatedBy<CitizenBasicI> by EntityCreatedByImp(createdBy) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.io.errors.IOException
|
||||
import fr.dcproject.repository.FollowArticle as FollowArticleRepository
|
||||
|
||||
|
||||
class ArticleUpdate(
|
||||
target: Article
|
||||
) : EntityEvent(target, "article", "update") {
|
||||
@@ -102,4 +101,4 @@ fun EventSubscriber.Configuration.configEvent(
|
||||
rabbitChannel.basicConsume("push", false, consumerPush) // The front consume the redis via Websocket
|
||||
rabbitChannel.basicConsume("email", false, consumerEmail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class EntityEvent(
|
||||
class EventSubscriber {
|
||||
class Configuration(private val monitor: ApplicationEvents) {
|
||||
private val subscribers = mutableListOf<DisposableHandle>()
|
||||
fun <T: Event> subscribe(definition: EventDefinition<T>, handler: EventHandler<T>): DisposableHandle {
|
||||
fun <T : Event> subscribe(definition: EventDefinition<T>, handler: EventHandler<T>): DisposableHandle {
|
||||
return monitor.subscribe(definition, handler).also {
|
||||
subscribers.add(it)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,14 @@ class Publisher(
|
||||
private val factory: ConnectionFactory,
|
||||
private val logger: Logger = LoggerFactory.getLogger(Publisher::class.qualifiedName)
|
||||
) {
|
||||
fun <T: EntityEvent>publish(it: T): Job {
|
||||
fun <T : EntityEvent> publish(it: T): Job {
|
||||
return GlobalScope.launch {
|
||||
factory.newConnection().use { connection -> connection.createChannel().use { channel ->
|
||||
channel.basicPublish(config.exchangeNotificationName, "", null, it.serialize().toByteArray())
|
||||
logger.debug("Publish message ${it.target.id}")
|
||||
} }
|
||||
factory.newConnection().use { connection ->
|
||||
connection.createChannel().use { channel ->
|
||||
channel.basicPublish(config.exchangeNotificationName, "", null, it.serialize().toByteArray())
|
||||
logger.debug("Publish message ${it.target.id}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ sealed class Follow<IN : TargetRef, OUT : TargetRef>(override var requester: Req
|
||||
): Paginated<FollowEntity<OUT>> {
|
||||
return requester
|
||||
.getFunction("find_follows_by_citizen")
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
.select(
|
||||
page, limit,
|
||||
"created_by_id" to citizenId
|
||||
)
|
||||
}
|
||||
|
||||
fun follow(follow: FollowEntity<IN>) {
|
||||
@@ -74,7 +74,7 @@ sealed class Follow<IN : TargetRef, OUT : TargetRef>(override var requester: Req
|
||||
paginate.result.forEach {
|
||||
emit(it)
|
||||
}
|
||||
nextPage = paginate.currentPage+1
|
||||
nextPage = paginate.currentPage + 1
|
||||
} while (!paginate.isLastPage())
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ class FollowArticle(requester: Requester) : Follow<ArticleRef, ArticleEntity>(re
|
||||
): Paginated<FollowSimple<ArticleRef, CitizenRef>> {
|
||||
return requester
|
||||
.getFunction("find_follows_article_by_target")
|
||||
.select(page, limit,
|
||||
.select(
|
||||
page, limit,
|
||||
"target_id" to target.id
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ class ArticleSteps : En, KoinTest {
|
||||
|
||||
Given("I have article") { extraData: DataTable ->
|
||||
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 id = params["id"]?.toUUID() ?: UUID.randomUUID()
|
||||
val article = ArticleEntity(
|
||||
@@ -59,7 +60,6 @@ class ArticleSteps : En, KoinTest {
|
||||
)
|
||||
get<ArticleRepository>().upsert(article)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.OpinionChoice as OpinionChoiceRepository
|
||||
|
||||
|
||||
class OpinionSteps : En, KoinTest {
|
||||
init {
|
||||
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 {
|
||||
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"),
|
||||
createdBy = get<CitizenRepository>().findById(citizen.toUUID()) ?: error("Citizen not exist")
|
||||
)
|
||||
@@ -25,12 +25,17 @@ 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 ->
|
||||
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(
|
||||
choice = params["opinion"]?.let { 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"),
|
||||
choice = params["opinion"]?.let {
|
||||
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")
|
||||
)
|
||||
get<OpinionRepository>().opinion(opinion)
|
||||
|
||||
Reference in New Issue
Block a user