File tree Expand file tree Collapse file tree
main/kotlin/com/baeldung/springbootkotlin
test/kotlin/springbootkotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.baeldung.springbootkotlin
22
3- import org.springframework.beans.factory.annotation.Autowired
43import org.springframework.web.bind.annotation.GetMapping
54import 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}
Original file line number Diff line number Diff line change 1+ package com.baeldung.springbootkotlin
2+
3+ data class HelloDto constructor(val greeting : String )
Load diff This file was deleted.
Original file line number Diff line number Diff line change 11package com.example.kotlindemo
22
3- import com.baeldung.springbootkotlin.HelloPoko
3+ import com.baeldung.springbootkotlin.HelloDto
44import com.baeldung.springbootkotlin.KotlinDemoApplication
55import org.junit.Assert
66import 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}
You can’t perform that action at this time.
0 commit comments