Skip to content

test: Native Test for a Kotlin DataClasss serialised with JacksonDatabind #11697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 28, 2025
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ graalVersion=21.0.5

org.gradle.caching=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx1g
org.gradle.jvmargs=-Xmx4g
systemProp.predictiveTestSelection=false
predictiveTestSelection=false

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ managed-groovy = "4.0.24"
managed-jakarta-annotation-api = "2.1.1"
managed-jackson = "2.17.2"
#@NextMajorVersion @Deprecated Delete in Micronaut Framework 5.
managed-jackson-databind = "2.17.0"
managed-jackson-databind = "2.17.2"
managed-kotlin = "1.9.25"
managed-kotlin-coroutines = "1.8.1"
managed-methvin-directory-watcher = "0.18.0"
Expand Down
1 change: 1 addition & 0 deletions test-suite-kotlin-graalvm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tasks.withType(Test).configureEach {
}

dependencies {
testImplementation(libs.managed.kotlin.reflect)
kspTest(projects.injectKotlin)
testImplementation(projects.httpServerNetty)
testImplementation(projects.httpClient)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package example.micronaut.jacksondatabind

import io.micronaut.context.annotation.Property
import io.micronaut.http.annotation.Get
import io.micronaut.http.client.annotation.Client
import io.micronaut.test.extensions.junit5.annotation.MicronautTest
import jakarta.inject.Inject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.reactivestreams.Publisher
import reactor.core.publisher.Flux

@Property(name = "spec.name", value = "JacksonDatabindDataClassSerialization")
@MicronautTest
class DataClassSerializationTest {

@Inject
lateinit var client: GreetingClient

@Test
fun testHelloGet() {
Assertions.assertEquals(
"Hola Mundo",
Flux.from(client.hello()).blockFirst()!!.message
)
}
}

@Property(name = "spec.name", value = "JacksonDatabindDataClassSerialization")
@Client("/")
interface GreetingClient {

@Get("/hola")
fun hello() : Publisher<Greeting>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package example.micronaut.jacksondatabind

import io.micronaut.context.annotation.Requires
import io.micronaut.core.annotation.Introspected
import io.micronaut.core.annotation.ReflectiveAccess

@Requires(property = "spec.name", value = "JacksonDatabindDataClassSerialization")
@Introspected
data class Greeting(val message: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package example.micronaut.jacksondatabind

import io.micronaut.context.annotation.Requires
import io.micronaut.context.annotation.Value
import jakarta.inject.Singleton
import reactor.core.publisher.Mono

@Requires(property = "spec.name", value = "JacksonDatabindDataClassSerialization")
@Singleton
class GreetingService {
fun sayHi(): Greeting = Greeting("Hola Mundo")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package example.micronaut.jacksondatabind

import io.micronaut.context.annotation.Requires
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get

@Requires(property = "spec.name", value = "JacksonDatabindDataClassSerialization")
@Controller
class HolaController(private val greetingService: GreetingService) {
@Get("/hola")
fun sayHi(): Greeting = greetingService.sayHi()
}
Loading