diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloController.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloController.kt index 02b57bac5f..69be7dac7e 100644 --- a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloController.kt +++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloController.kt @@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RestController @RestController -class HelloController constructor(val helloService: HelloService) { +class HelloController(val helloService: HelloService) { @GetMapping("/hello") fun helloKotlin(): String { diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt index 3f0139b5a9..f61c101f0f 100644 --- a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt +++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt @@ -1,3 +1,3 @@ package com.baeldung.springbootkotlin -data class HelloDto constructor(val greeting: String) +data class HelloDto(val greeting: String) diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloService.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloService.kt index c988b64e05..67791a0c2d 100644 --- a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloService.kt +++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloService.kt @@ -4,6 +4,7 @@ import org.springframework.stereotype.Service @Service class HelloService { + fun getHello(): String { return "hello service" } diff --git a/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt b/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt index 15ddc916e2..e0d427e52f 100644 --- a/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt +++ b/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt @@ -1,4 +1,4 @@ -package com.example.kotlindemo +package springbootkotlin import com.baeldung.springbootkotlin.HelloDto import com.baeldung.springbootkotlin.KotlinDemoApplication @@ -24,7 +24,7 @@ class KotlinDemoApplicationTests { @Test fun testHelloController() { - var result = testRestTemplate?.getForEntity("/hello", String::class.java) + val result = testRestTemplate?.getForEntity("/hello", String::class.java) Assert.assertNotNull(result) Assert.assertEquals(result?.statusCode, HttpStatus.OK) @@ -33,7 +33,7 @@ class KotlinDemoApplicationTests { @Test fun testHelloService() { - var result = testRestTemplate?.getForEntity("/hello-service", String::class.java) + val result = testRestTemplate?.getForEntity("/hello-service", String::class.java) Assert.assertNotNull(result) Assert.assertEquals(result?.statusCode, HttpStatus.OK) @@ -42,7 +42,7 @@ class KotlinDemoApplicationTests { @Test fun testHelloDto() { - var result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java) + val result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java) Assert.assertNotNull(result) Assert.assertEquals(result?.statusCode, HttpStatus.OK)