Merge pull request #1972 from eugenp/spring-kotlin-refactor

Kotlin refactor
This commit is contained in:
slavisa-baeldung 2017-06-02 10:46:46 +02:00 committed by GitHub
commit d614fc2fa7
4 changed files with 7 additions and 6 deletions

View File

@ -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 {

View File

@ -1,3 +1,3 @@
package com.baeldung.springbootkotlin
data class HelloDto constructor(val greeting: String)
data class HelloDto(val greeting: String)

View File

@ -4,6 +4,7 @@ import org.springframework.stereotype.Service
@Service
class HelloService {
fun getHello(): String {
return "hello service"
}

View File

@ -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)