From ea302a5f335334c69c7467c65525913ec8a14985 Mon Sep 17 00:00:00 2001 From: tschiman Date: Wed, 31 May 2017 16:31:02 -0600 Subject: [PATCH] BAEL-755 changing the name of the POKO to a DTO and removing the use of @Autowired in the constructor as it is not needed. --- .../com/baeldung/springbootkotlin/HelloController.kt | 9 ++++----- .../kotlin/com/baeldung/springbootkotlin/HelloDto.kt | 3 +++ .../kotlin/com/baeldung/springbootkotlin/HelloPoko.kt | 3 --- .../springbootkotlin/KotlinDemoApplicationTests.kt | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt delete mode 100644 spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloPoko.kt 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 622271211b..02b57bac5f 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 @@ -1,11 +1,10 @@ package com.baeldung.springbootkotlin -import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RestController @RestController -class HelloController @Autowired constructor(val helloService: HelloService) { +class HelloController constructor(val helloService: HelloService) { @GetMapping("/hello") fun helloKotlin(): String { @@ -17,8 +16,8 @@ class HelloController @Autowired constructor(val helloService: HelloService) { return helloService.getHello() } - @GetMapping("/hello-poko") - fun helloPoko(): HelloPoko { - return HelloPoko("Hello from the poko") + @GetMapping("/hello-dto") + fun helloDto(): HelloDto { + return HelloDto("Hello from the dto") } } \ No newline at end of file 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 new file mode 100644 index 0000000000..3f0139b5a9 --- /dev/null +++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloDto.kt @@ -0,0 +1,3 @@ +package com.baeldung.springbootkotlin + +data class HelloDto constructor(val greeting: String) diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloPoko.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloPoko.kt deleted file mode 100644 index 7e9c50e073..0000000000 --- a/spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloPoko.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.baeldung.springbootkotlin - -data class HelloPoko constructor(val greeting: String) diff --git a/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt b/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt index c6d9146edd..08c9ad0889 100644 --- a/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt +++ b/spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt @@ -1,6 +1,6 @@ package com.example.kotlindemo -import com.baeldung.springbootkotlin.HelloPoko +import com.baeldung.springbootkotlin.HelloDto import com.baeldung.springbootkotlin.KotlinDemoApplication import org.junit.Assert import org.junit.Test @@ -42,11 +42,11 @@ class KotlinDemoApplicationTests { @Test fun testHelloPoko() { - var result = testRestTemplate?.getForEntity("/hello-poko", HelloPoko::class.java) + var result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java) Assert.assertNotNull(result) Assert.assertEquals(result?.statusCode, HttpStatus.OK) - Assert.assertEquals(result?.body, HelloPoko("Hello from the poko")) + Assert.assertEquals(result?.body, HelloDto("Hello from the dto")) } }