Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.baeldung.springbootkotlin

data class HelloDto constructor(val greeting: String)
data class HelloDto(val greeting: String)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.springframework.stereotype.Service

@Service
class HelloService {

fun getHello(): String {
return "hello service"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlindemo
package springbootkotlin

import com.baeldung.springbootkotlin.HelloDto
import com.baeldung.springbootkotlin.KotlinDemoApplication
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down