Skip to content

Commit 4310c79

Browse files
committed
Polishing
Signed-off-by: Sébastien Deleuze <sdeleuze@users.noreply.github.com>
1 parent d41a269 commit 4310c79

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

README.adoc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To manually initialize the project:
3434

3535
. Navigate to https://start.spring.io.
3636
This service pulls in all the dependencies you need for an application and does most of the setup for you.
37-
. Choose either Gradle or Maven and the language you want to use: Kotlin or Java.
37+
. Choose either Gradle or Maven and the language you want to use.
3838
. Click *Dependencies* and select *Spring Web*.
3939
. Click *Generate*.
4040
. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices.
@@ -59,10 +59,6 @@ include::complete/src/main/java/com/example/testingweb/HomeController.java[]
5959
include::complete-kotlin/src/main/kotlin/com/example/testingweb/HomeController.kt[]
6060
----
6161

62-
NOTE: The preceding example does not specify `GET` versus `PUT`, `POST`, and so forth.
63-
By default `@RequestMapping` maps all HTTP operations. You can use `@GetMapping` or
64-
`@RequestMapping(method=GET)` to narrow this mapping.
65-
6662

6763
== Run the Application
6864

@@ -253,7 +249,7 @@ include::complete/src/test/java/com/example/testingweb/WebMockTest.java[]
253249
include::complete-kotlin/src/test/kotlin/com/example/testingweb/WebMockTest.kt[]
254250
----
255251

256-
We use `@MockBean` to create and inject a mock for the `GreetingService` (if you do not do
252+
We use `@MockitoBean` to create and inject a mock for the `GreetingService` (if you do not do
257253
so, the application context cannot start), and we set its expectations using `Mockito`.
258254

259255
== Summary
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.example.testingweb
22

3-
import org.springframework.stereotype.Controller
4-
import org.springframework.web.bind.annotation.RequestMapping
5-
import org.springframework.web.bind.annotation.ResponseBody
3+
import org.springframework.web.bind.annotation.GetMapping
4+
import org.springframework.web.bind.annotation.RestController
65

7-
@Controller
6+
@RestController
87
class GreetingController(private val service: GreetingService) {
98

10-
@RequestMapping("/greeting")
11-
@ResponseBody
9+
@GetMapping("/greeting")
1210
fun greeting(): String = service.greet()
1311
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.example.testingweb
22

3-
import org.springframework.stereotype.Controller
4-
import org.springframework.web.bind.annotation.RequestMapping
5-
import org.springframework.web.bind.annotation.ResponseBody
3+
import org.springframework.web.bind.annotation.GetMapping
4+
import org.springframework.web.bind.annotation.RestController
65

7-
@Controller
6+
@RestController
87
class HomeController {
98

10-
@RequestMapping("/")
11-
@ResponseBody
9+
@GetMapping("/")
1210
fun greeting(): String = "Hello, World"
1311
}

complete/src/main/java/com/example/testingweb/GreetingController.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.example.testingweb;
22

3-
import org.springframework.stereotype.Controller;
4-
import org.springframework.web.bind.annotation.RequestMapping;
5-
import org.springframework.web.bind.annotation.ResponseBody;
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
65

76

8-
@Controller
7+
@RestController
98
public class GreetingController {
109

1110
private final GreetingService service;
@@ -14,8 +13,8 @@ public GreetingController(GreetingService service) {
1413
this.service = service;
1514
}
1615

17-
@RequestMapping("/greeting")
18-
public @ResponseBody String greeting() {
16+
@GetMapping("/greeting")
17+
public String greeting() {
1918
return service.greet();
2019
}
2120

complete/src/main/java/com/example/testingweb/HomeController.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package com.example.testingweb;
22

3-
import org.springframework.stereotype.Controller;
4-
import org.springframework.web.bind.annotation.RequestMapping;
5-
import org.springframework.web.bind.annotation.ResponseBody;
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
65

7-
@Controller
6+
@RestController
87
public class HomeController {
98

10-
@RequestMapping("/")
11-
public @ResponseBody String greeting() {
9+
@GetMapping("/")
10+
public String greeting() {
1211
return "Hello, World";
1312
}
1413

0 commit comments

Comments
 (0)