Skip to content

Commit 639bc98

Browse files
Merge pull request eugenp#1967 from tschiman/master
BAEL-755 Updating code with suggested changes
2 parents 8edc3bf + 50cf9a5 commit 639bc98

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.baeldung.springbootkotlin
22

3-
import org.springframework.beans.factory.annotation.Autowired
43
import org.springframework.web.bind.annotation.GetMapping
54
import org.springframework.web.bind.annotation.RestController
65

76
@RestController
8-
class HelloController @Autowired constructor(val helloService: HelloService) {
7+
class HelloController constructor(val helloService: HelloService) {
98

109
@GetMapping("/hello")
1110
fun helloKotlin(): String {
@@ -17,8 +16,8 @@ class HelloController @Autowired constructor(val helloService: HelloService) {
1716
return helloService.getHello()
1817
}
1918

20-
@GetMapping("/hello-poko")
21-
fun helloPoko(): HelloPoko {
22-
return HelloPoko("Hello from the poko")
19+
@GetMapping("/hello-dto")
20+
fun helloDto(): HelloDto {
21+
return HelloDto("Hello from the dto")
2322
}
2423
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.baeldung.springbootkotlin
2+
3+
data class HelloDto constructor(val greeting: String)

‎spring-boot-kotlin/src/main/kotlin/com/baeldung/springbootkotlin/HelloPoko.kt‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎spring-boot-kotlin/src/test/kotlin/springbootkotlin/KotlinDemoApplicationTests.kt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.kotlindemo
22

3-
import com.baeldung.springbootkotlin.HelloPoko
3+
import com.baeldung.springbootkotlin.HelloDto
44
import com.baeldung.springbootkotlin.KotlinDemoApplication
55
import org.junit.Assert
66
import org.junit.Test
@@ -41,12 +41,12 @@ class KotlinDemoApplicationTests {
4141
}
4242

4343
@Test
44-
fun testHelloPoko() {
45-
var result = testRestTemplate?.getForEntity("/hello-poko", HelloPoko::class.java)
44+
fun testHelloDto() {
45+
var result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java)
4646

4747
Assert.assertNotNull(result)
4848
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
49-
Assert.assertEquals(result?.body, HelloPoko("Hello from the poko"))
49+
Assert.assertEquals(result?.body, HelloDto("Hello from the dto"))
5050
}
5151

5252
}

0 commit comments

Comments
 (0)