Update dependencies
Fix for koin 3.0
This commit is contained in:
@@ -15,7 +15,6 @@ import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.koin.test.AutoCloseKoinTest
|
||||
import org.koin.test.KoinTest
|
||||
import org.koin.test.get
|
||||
|
||||
@@ -23,7 +22,7 @@ import org.koin.test.get
|
||||
@KtorExperimentalAPI
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
@Tags(Tag("functional"), Tag("mail"))
|
||||
class MailerTest : KoinTest, AutoCloseKoinTest() {
|
||||
class MailerTest : KoinTest {
|
||||
@InternalCoroutinesApi
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
|
||||
@@ -46,7 +46,7 @@ fun createArticle(
|
||||
workgroup: WorkgroupRef? = null,
|
||||
createdBy: CitizenRef = createCitizen()
|
||||
): ArticleForView {
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
val article = ArticleForUpdate(
|
||||
id = id ?: UUID.randomUUID(),
|
||||
|
||||
@@ -14,9 +14,9 @@ fun TestApplicationRequest.`authenticated as`(
|
||||
lastName: String,
|
||||
): Citizen {
|
||||
val username = "$firstName-$lastName".toLowerCase()
|
||||
val repo: CitizenRepository by lazy<CitizenRepository> { GlobalContext.get().koin.get() }
|
||||
val repo: CitizenRepository by lazy<CitizenRepository> { GlobalContext.get().get() }
|
||||
val citizen = repo.findByUsername(username) ?: error("Citizen not exist with username $username")
|
||||
val algorithm = GlobalContext.get().koin.get<JwtConfig>().algorithm
|
||||
val algorithm = GlobalContext.get().get<JwtConfig>().algorithm
|
||||
val jwtAsString: String = JWT.create()
|
||||
.withIssuer("dc-project.fr")
|
||||
.withClaim("id", citizen.user.id.toString())
|
||||
@@ -30,9 +30,9 @@ fun TestApplicationRequest.`authenticated in url as`(
|
||||
firstName: String,
|
||||
lastName: String,
|
||||
): Citizen {
|
||||
val repo: CitizenRepository by lazy<CitizenRepository> { GlobalContext.get().koin.get() }
|
||||
val repo: CitizenRepository by lazy<CitizenRepository> { GlobalContext.get().get() }
|
||||
val citizen = repo.findByName(CitizenI.Name(firstName, lastName)) ?: error("Citizen not exist with name $firstName $lastName")
|
||||
val algorithm = GlobalContext.get().koin.get<JwtConfig>().algorithm
|
||||
val algorithm = GlobalContext.get().get<JwtConfig>().algorithm
|
||||
val jwtAsString: String = JWT.create()
|
||||
.withIssuer("dc-project.fr")
|
||||
.withClaim("id", citizen.user.id.toString())
|
||||
|
||||
@@ -18,7 +18,7 @@ fun TestApplicationEngine.`Given I have citizen`(
|
||||
id: String = UUID.randomUUID().toString(),
|
||||
callback: Citizen.() -> Unit = {}
|
||||
): Citizen? {
|
||||
val repo: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val repo: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
val user = UserForCreate(
|
||||
id = id.toUUID(),
|
||||
@@ -37,7 +37,7 @@ fun TestApplicationEngine.`Given I have citizen`(
|
||||
}
|
||||
|
||||
fun createCitizen(name: CitizenI.Name? = null, id: UUID = UUID.randomUUID()): Citizen {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
return if (name != null) {
|
||||
citizenRepository.findByName(name) ?: error("Citizen not exist")
|
||||
|
||||
@@ -43,7 +43,7 @@ fun <A : ArticleRef> createComment(
|
||||
createdBy: Name? = null,
|
||||
content: String? = null
|
||||
): CommentForView<TargetRef, CitizenCreator> {
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().get() }
|
||||
return createCommentOnTarget(
|
||||
id,
|
||||
article?.id?.let { articleRepository.findById(article.id) } ?: createArticle(article?.id),
|
||||
@@ -67,7 +67,7 @@ fun <C : ConstitutionRef> createComment(
|
||||
createdBy: Name? = null,
|
||||
content: String? = null
|
||||
): CommentForView<TargetRef, CitizenCreator> {
|
||||
val constitutionRepository: ConstitutionRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val constitutionRepository: ConstitutionRepository by lazy { GlobalContext.get().get() }
|
||||
return createCommentOnTarget(
|
||||
id,
|
||||
constitution?.id?.let { constitutionRepository.findById(constitution.id) } ?: createConstitution(constitution?.id),
|
||||
@@ -82,7 +82,7 @@ fun <T : TargetI> createCommentOnTarget(
|
||||
createdBy: Name? = null,
|
||||
content: String? = null
|
||||
): CommentForView<TargetRef, CitizenCreator> {
|
||||
val commentRepository: CommentRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val commentRepository: CommentRepository by lazy { GlobalContext.get().get() }
|
||||
val creator = createCitizen(createdBy)
|
||||
val comment = CommentForUpdate(
|
||||
id = id ?: UUID.randomUUID(),
|
||||
@@ -114,7 +114,7 @@ fun createCommentOnComment(
|
||||
content: String? = null
|
||||
): CommentForView<out TargetRef, CitizenCreator> {
|
||||
val creator = createCitizen(createdBy)
|
||||
val commentRepository: CommentRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val commentRepository: CommentRepository by lazy { GlobalContext.get().get() }
|
||||
val parentComment = if (parent == null) {
|
||||
createComment<ArticleRef>()
|
||||
} else {
|
||||
|
||||
@@ -44,7 +44,7 @@ fun createConstitution(
|
||||
titles: List<TitleForUpdate<ArticleRef>>? = null,
|
||||
createdBy: Name? = null
|
||||
): ConstitutionForView {
|
||||
val constitutionRepository: ConstitutionRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val constitutionRepository: ConstitutionRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
val creator: CitizenWithUserI = createCitizen(createdBy)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ fun TestApplicationEngine.`Given I have follow on article`(
|
||||
lastName: String,
|
||||
article: String,
|
||||
) {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val citizen = citizenRepository.findByName(CitizenI.Name(firstName, lastName)) ?: error("Citizen not exist")
|
||||
createFollow(citizen, ArticleRef(article.toUUID()))
|
||||
}
|
||||
@@ -40,19 +40,19 @@ fun TestApplicationEngine.`Given I have follow on constitution`(
|
||||
lastName: String,
|
||||
constitution: String,
|
||||
) {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val citizen = citizenRepository.findByName(CitizenI.Name(firstName, lastName)) ?: error("Citizen not exist")
|
||||
createFollow(citizen, ArticleRef(constitution.toUUID()))
|
||||
}
|
||||
|
||||
fun createFollow(citizen: CitizenRef, article: ArticleRef) {
|
||||
val followArticleRepository: FollowArticleRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val followArticleRepository: FollowArticleRepository by lazy { GlobalContext.get().get() }
|
||||
val follow = FollowForUpdate(createdBy = citizen, target = article)
|
||||
followArticleRepository.follow(follow)
|
||||
}
|
||||
|
||||
fun createFollow(citizen: CitizenRef, constitution: ConstitutionRef) {
|
||||
val followConstitutionRepository: FollowConstitutionRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val followConstitutionRepository: FollowConstitutionRepository by lazy { GlobalContext.get().get() }
|
||||
val follow = FollowForUpdate(createdBy = citizen, target = constitution)
|
||||
followConstitutionRepository.follow(follow)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ fun createOpinionChoice(
|
||||
id: UUID? = null,
|
||||
name: String,
|
||||
): OpinionChoice {
|
||||
val opinionChoiceRepository: OpinionChoiceRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val opinionChoiceRepository: OpinionChoiceRepository by lazy { GlobalContext.get().get() }
|
||||
val opinionChoice = OpinionChoice(
|
||||
id = id,
|
||||
name = name,
|
||||
@@ -38,9 +38,9 @@ fun `Given I have opinion on article`(
|
||||
citizenName: Name,
|
||||
id: String? = null
|
||||
) {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val opinionRepositoryArticle: OpinionRepositoryArticle by lazy { GlobalContext.get().koin.get() }
|
||||
val opinionChoiceRepository: OpinionChoiceRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val opinionRepositoryArticle: OpinionRepositoryArticle by lazy { GlobalContext.get().get() }
|
||||
val opinionChoiceRepository: OpinionChoiceRepository by lazy { GlobalContext.get().get() }
|
||||
val opinion = OpinionForUpdate(
|
||||
id = id?.toUUID() ?: UUID.randomUUID(),
|
||||
choice = opinionChoiceRepository.findOpinionsChoiceByName(name)
|
||||
|
||||
@@ -33,9 +33,9 @@ fun createVote(
|
||||
note: Int,
|
||||
id: UUID? = null,
|
||||
): VoteAggregation {
|
||||
val voteArticleRepository: VoteArticleRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val voteArticleRepository: VoteArticleRepository by lazy { GlobalContext.get().get() }
|
||||
val articleRepository: ArticleRepository by lazy { GlobalContext.get().get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val vote = VoteForUpdate(
|
||||
id = id ?: UUID.randomUUID(),
|
||||
note = note,
|
||||
|
||||
@@ -36,8 +36,8 @@ fun WorkgroupForView<CitizenCreator>.`With members`(
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun addMemberToWorkgroup(workgroup: WorkgroupForView<CitizenCreator>, vararg membersNames: CitizenI.Name) {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
val newMembers: List<Member<CitizenI>> = membersNames.map { memberName ->
|
||||
val member: Citizen = citizenRepository.findByName(memberName) ?: error("Citizen not exist")
|
||||
@@ -56,8 +56,8 @@ private fun createWorkgroup(
|
||||
anonymous: Boolean? = null,
|
||||
createdBy: CitizenI.Name? = null,
|
||||
): WorkgroupForView<CitizenCreator> {
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().koin.get() }
|
||||
val citizenRepository: CitizenRepository by lazy { GlobalContext.get().get() }
|
||||
val workgroupRepository: WorkgroupRepository by lazy { GlobalContext.get().get() }
|
||||
|
||||
val creatorName = createdBy ?: CitizenI.Name("Paul", "Langevin")
|
||||
val creator = citizenRepository.findByName(creatorName) ?: run {
|
||||
|
||||
Reference in New Issue
Block a user