Skip to content

Commit d614fc2

Browse files
Merge pull request eugenp#1972 from eugenp/spring-kotlin-refactor
Kotlin refactor
2 parents b7b1693 + 19d084e commit d614fc2

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.GetMapping
44
import org.springframework.web.bind.annotation.RestController
55

66
@RestController
7-
class HelloController constructor(val helloService: HelloService) {
7+
class HelloController(val helloService: HelloService) {
88

99
@GetMapping("/hello")
1010
fun helloKotlin(): String {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.baeldung.springbootkotlin
22

3-
data class HelloDto constructor(val greeting: String)
3+
data class HelloDto(val greeting: String)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.springframework.stereotype.Service
44

55
@Service
66
class HelloService {
7+
78
fun getHello(): String {
89
return "hello service"
910
}

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

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

33
import com.baeldung.springbootkotlin.HelloDto
44
import com.baeldung.springbootkotlin.KotlinDemoApplication
@@ -24,7 +24,7 @@ class KotlinDemoApplicationTests {
2424

2525
@Test
2626
fun testHelloController() {
27-
var result = testRestTemplate?.getForEntity("/hello", String::class.java)
27+
val result = testRestTemplate?.getForEntity("/hello", String::class.java)
2828

2929
Assert.assertNotNull(result)
3030
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
@@ -33,7 +33,7 @@ class KotlinDemoApplicationTests {
3333

3434
@Test
3535
fun testHelloService() {
36-
var result = testRestTemplate?.getForEntity("/hello-service", String::class.java)
36+
val result = testRestTemplate?.getForEntity("/hello-service", String::class.java)
3737

3838
Assert.assertNotNull(result)
3939
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
@@ -42,7 +42,7 @@ class KotlinDemoApplicationTests {
4242

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

4747
Assert.assertNotNull(result)
4848
Assert.assertEquals(result?.statusCode, HttpStatus.OK)

0 commit comments

Comments
 (0)