Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
kotlin = "2.2.10"
kotlinx = "1.10.2"
kotest = "6.0.5"
detekt = "1.23.8"
junit = "5.14.1"
koin = "4.1.1"
quarkus = "3.30.0"
jakarta = "4.1.0"
spring-boot-2x = "2.7.18"
spring-boot-3x = "3.5.8"
spring-boot-4x = "4.0.0"
ktlint = "1.8.0"

[libraries]
Expand All @@ -20,8 +20,10 @@ quarkusBom = { module = "io.quarkus:quarkus-bom", version.ref = "quarkus" }
quarkus-arc = { module = "io.quarkus:quarkus-arc", version.ref = "quarkus" }
jakarta-enterpise-cdi-api = { module = "jakarta.enterprise:jakarta.enterprise.cdi-api", version.ref = "jakarta" }

spring-boot-4x-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "spring-boot-4x" }
spring-boot-4x-starter-test = { module = "org.springframework.boot:spring-boot-starter-test", version.ref = "spring-boot-4x" }

spring-boot-3x-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "spring-boot-3x" }
spring-boot-3x-autoconfigure = { module = "org.springframework.boot:spring-boot-autoconfigure", version.ref = "spring-boot-3x" }
spring-boot-3x-starter-test = { module = "org.springframework.boot:spring-boot-starter-test", version.ref = "spring-boot-3x" }

spring-boot-2x-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "spring-boot-2x" }
Expand All @@ -30,20 +32,17 @@ ktlint-cli = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint

# test
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
kotest-assertions-arrow = { module = "io.kotest.extensions:kotest-assertions-arrow", version = "2.0.0" }
kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
kotest-assertions-table = { module = "io.kotest:kotest-assertions-table", version.ref = "kotest" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx" }
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
koin-test-junit5 = { module = "io.insert-koin:koin-test-junit5", version.ref = "koin" }
quarkus-junit5 = { module = "io.quarkus:quarkus-junit5", version.ref = "quarkus" }
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }

[plugins]
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.9.3" }
testLogger = { id = "com.adarshr.test-logger", version = "4.0.0" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
spotless = { id = "com.diffplug.spotless", version = "8.1.0" }
quarkus = { id = "io.quarkus", version.ref = "quarkus" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.35.0" }
1 change: 0 additions & 1 deletion projects/kediatr-spring-boot-3x-starter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
dependencies {
api(projects.projects.kediatrCore)
implementation(libs.spring.boot.get3x().starter)
implementation(libs.spring.boot.get3x().autoconfigure)
}

dependencies {
Expand Down
9 changes: 9 additions & 0 deletions projects/kediatr-spring-boot-4x-starter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies {
api(projects.projects.kediatrCore)
implementation(libs.spring.boot.get4x().starter)
}

dependencies {
testImplementation(testFixtures(projects.projects.kediatrCore))
testImplementation(libs.spring.boot.get4x().starter.test)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.trendyol.kediatr.spring

import com.trendyol.kediatr.Mediator
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean

@AutoConfiguration
open class KediatRAutoConfiguration {
@Bean
@ConditionalOnMissingBean
open fun kediatRSpringBeanProvider(
applicationContext: ApplicationContext
): KediatRSpringBeanProvider = KediatRSpringBeanProvider(applicationContext)

@Bean
@ConditionalOnMissingBean
open fun mediator(
kediatRSpringBeanProvider: KediatRSpringBeanProvider
): Mediator = Mediator.build(kediatRSpringBeanProvider)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@file:Suppress("UNCHECKED_CAST")

package com.trendyol.kediatr.spring

import com.trendyol.kediatr.DependencyProvider
import org.springframework.context.ApplicationContext

class KediatRSpringBeanProvider(
private val applicationContext: ApplicationContext
) : DependencyProvider {
override fun <T> getSingleInstanceOf(clazz: Class<T>): T = applicationContext
.getBeanNamesForType(clazz)
.single()
.let { applicationContext.getBean(it) as T }

override fun <T> getSubTypesOf(
clazz: Class<T>
): Collection<Class<T>> = applicationContext
.getBeanNamesForType(clazz)
.map { applicationContext.getType(it) as Class<T> }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.trendyol.kediatr.spring.KediatRAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.trendyol.kediatr.spring

import com.trendyol.kediatr.Mediator
import com.trendyol.kediatr.testing.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.*

@SpringBootTest(
classes = [
KediatRAutoConfiguration::class,
MediatorTests.TestConfiguration::class,
TestRequestHandler::class,
ExceptionPipelineBehavior::class,
LoggingPipelineBehavior::class,
TestQueryHandler::class,
TestNotificationHandler::class,
TestBrokenRequestHandler::class,
TestPipelineRequestHandler::class,
TestCommandWithResultRequestHandler::class,
TestInheritedRequestHandlerForSpecificCommand::class,
TestRequestHandlerWithoutInjection::class,
TestRequestHandlerForTypeLimitedInheritance::class,
ParameterizedRequestHandler::class,
ParameterizedRequestHandlerForInheritance::class,
ParameterizedCommandWithResultHandler::class,
ParameterizedCommandWithResultHandlerOfInheritedHandler::class,
APingHandler::class,
AnotherPingHandler::class,
Handler1ForNotificationOfMultipleHandlers::class,
Handler2ForNotificationOfMultipleHandlers::class,
InheritedNotificationHandler::class,
InheritedNotificationHandler2::class,
ParameterizedNotificationHandler::class,
ParameterizedNotificationHandlerForInheritance::class,
TestPipelineRequestHandlerWithoutInjection::class,
TestPipelineRequestHandlerThatFails::class,
InheritedPipelineBehaviour::class,
ParameterizedQueryHandler::class,
FirstPipelineBehaviour::class,
SecondPipelineBehaviour::class,
ThirdPipelineBehaviour::class,
RequestHandlerThatPassesThroughOrderedPipelineBehaviours::class,
QueryHandlerThatPassesThroughOrderedPipelineBehaviours::class,
NotificationHandlerThatPassesThroughOrderedPipelineBehaviours::class,
TestCommandBaseHandler::class,
TestQueryBaseHandler::class,
TestCommandWithResultBaseHandler::class,
TestCommandForInheritanceWithFallbackHandlerHandler::class,
TestRequestHandlerForCommandInherited2::class,
ModifyingPipelineBehavior::class,
TimingPipelineBehavior::class,
ConditionalPipelineBehavior::class,
RequestWithNullableResultHandler::class,
RequestWithNullParameterHandler::class,
NestedGenericRequestHandler::class,
WildcardGenericRequestHandler::class,
ConcurrentRequestHandler::class,
LongRunningRequestHandler::class,
MultiInterfaceRequestHandler::class,
EmptyRequestHandler::class,
VoidResultRequestHandler::class,
CollectionRequestHandler::class,
RequestThatThrowsSpecificExceptionHandler::class,
RequestThatThrowsRuntimeExceptionHandler::class,
ComplexPipelineRequestHandler::class,
ComplexDataRequestHandler::class,
NotificationThatThrowsExceptionHandler1::class,
NotificationThatThrowsExceptionHandler2::class,
NotificationThatThrowsExceptionHandler3::class,
SlowNotificationHandler1::class,
SlowNotificationHandler2::class,
SlowNotificationHandler3::class,
SelfReferencingRequestHandler::class,
CatchAllNotificationsHandler::class
]
)
class MediatorTests : MediatorUseCases() {
@Autowired
lateinit var mediator: Mediator

override fun provideMediator(): Mediator = mediator

@Configuration
open class TestConfiguration {
@Bean
open fun mediatorAccessor(mediator: Mediator): MediatorAccessor = { mediator }
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include(
"projects:kediatr-quarkus-starter",
"projects:kediatr-spring-boot-2x-starter",
"projects:kediatr-spring-boot-3x-starter",
"projects:kediatr-spring-boot-4x-starter",
)

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
Expand Down