From 6d64948c3acee50105f673420e396dcad925930d Mon Sep 17 00:00:00 2001 From: khalilou88 <32600911+khalilou88@users.noreply.github.com> Date: Fri, 29 Dec 2023 00:49:42 +0100 Subject: [PATCH] work in progress --- .gitignore | 1 + .../micronaut/micronautktapp/Application.kt | 4 ++-- .../micronautktapp/HelloController.kt | 11 +++++---- .../micronautktapp/HelloControllerTest.kt | 23 ++++++++++--------- .../MicronautMicronautKtAppTest.kt | 16 ++++++------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 6e97fbe..4e360f6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ node_modules # IDEs and editors .idea +*.iml .project .classpath .c9/ diff --git a/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/Application.kt b/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/Application.kt index 43348dc..58e0e1c 100644 --- a/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/Application.kt +++ b/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/Application.kt @@ -1,7 +1,7 @@ package com.example.micronaut.micronautktapp import io.micronaut.runtime.Micronaut.run + fun main(args: Array) { - run(*args) + run(*args) } - diff --git a/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/HelloController.kt b/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/HelloController.kt index a2bcc26..06c92cb 100644 --- a/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/HelloController.kt +++ b/nx-maven/micronaut/micronaut-kt-app/src/main/kotlin/com/example/micronaut/micronautktapp/HelloController.kt @@ -8,9 +8,10 @@ import io.micronaut.http.annotation.Produces import jakarta.inject.Inject @Controller("/hello") -class HelloController(@Inject val helloService: HelloService) { - - @Get - @Produces(MediaType.TEXT_PLAIN) - fun index() = helloService.greeting() +class HelloController( + @Inject val helloService: HelloService, +) { + @Get + @Produces(MediaType.TEXT_PLAIN) + fun index() = helloService.greeting() } diff --git a/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/HelloControllerTest.kt b/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/HelloControllerTest.kt index 6fea5cf..5e9d7c3 100644 --- a/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/HelloControllerTest.kt +++ b/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/HelloControllerTest.kt @@ -8,14 +8,15 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test -@MicronautTest -class HelloControllerTest(@Client("/") val client: HttpClient) { - - @Test - fun testHello() { - val request: HttpRequest = HttpRequest.GET("/hello") - val body = client.toBlocking().retrieve(request) - assertNotNull(body) - assertEquals("Hello World", body) - } -} \ No newline at end of file +@MicronautTest +class HelloControllerTest( + @Client("/") val client: HttpClient, +) { + @Test + fun testHello() { + val request: HttpRequest = HttpRequest.GET("/hello") + val body = client.toBlocking().retrieve(request) + assertNotNull(body) + assertEquals("Hello World", body) + } +} diff --git a/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/MicronautMicronautKtAppTest.kt b/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/MicronautMicronautKtAppTest.kt index c373e05..68ac860 100644 --- a/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/MicronautMicronautKtAppTest.kt +++ b/nx-maven/micronaut/micronaut-kt-app/src/test/kotlin/com/example/micronaut/micronautktapp/MicronautMicronautKtAppTest.kt @@ -2,19 +2,17 @@ package com.example.micronaut.micronautktapp import io.micronaut.runtime.EmbeddedApplication 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 jakarta.inject.Inject @MicronautTest class MicronautMicronautKtAppTest { + @Inject + lateinit var application: EmbeddedApplication<*> - @Inject - lateinit var application: EmbeddedApplication<*> - - @Test - fun testItWorks() { - Assertions.assertTrue(application.isRunning) - } - + @Test + fun testItWorks() { + Assertions.assertTrue(application.isRunning) + } }