Kotlin refactor
This commit is contained in:
parent
3cf4dc5a78
commit
19d084e728
|
@ -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 {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package com.baeldung.springbootkotlin
|
||||
|
||||
data class HelloDto constructor(val greeting: String)
|
||||
data class HelloDto(val greeting: String)
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.springframework.stereotype.Service
|
|||
|
||||
@Service
|
||||
class HelloService {
|
||||
|
||||
fun getHello(): String {
|
||||
return "hello service"
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue