Fix expectations in MockMvc Kotlin documentation

Closes gh-28301
This commit is contained in:
Sébastien Deleuze 2022-07-13 10:06:41 +02:00
parent 1201af20e4
commit c942c8d2cf
1 changed files with 6 additions and 6 deletions

View File

@ -7367,7 +7367,7 @@ no other expectations will be asserted.
import org.springframework.test.web.servlet.get import org.springframework.test.web.servlet.get
mockMvc.get("/accounts/1").andExpect { mockMvc.get("/accounts/1").andExpect {
status().isOk() status { isOk() }
} }
---- ----
@ -7415,7 +7415,7 @@ The following test asserts that binding or validation failed:
import org.springframework.test.web.servlet.post import org.springframework.test.web.servlet.post
mockMvc.post("/persons").andExpect { mockMvc.post("/persons").andExpect {
status().isOk() status { isOk() }
model { model {
attributeHasErrors("person") attributeHasErrors("person")
} }
@ -7443,7 +7443,7 @@ request. You can do so as follows, where `print()` is a static import from
mockMvc.post("/persons").andDo { mockMvc.post("/persons").andDo {
print() print()
}.andExpect { }.andExpect {
status().isOk() status { isOk() }
model { model {
attributeHasErrors("person") attributeHasErrors("person")
} }
@ -7473,7 +7473,7 @@ other expectations, as the following example shows:
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin .Kotlin
---- ----
var mvcResult = mockMvc.post("/persons").andExpect { status().isOk() }.andReturn() var mvcResult = mockMvc.post("/persons").andExpect { status { isOk() } }.andReturn()
// ... // ...
---- ----
@ -7593,7 +7593,7 @@ or reactive type such as Reactor `Mono`:
@Test @Test
fun test() { fun test() {
var mvcResult = mockMvc.get("/path").andExpect { var mvcResult = mockMvc.get("/path").andExpect {
status().isOk() // <1> status { isOk() } // <1>
request { asyncStarted() } // <2> request { asyncStarted() } // <2>
// TODO Remove unused generic parameter // TODO Remove unused generic parameter
request { asyncResult<Nothing>("body") } // <3> request { asyncResult<Nothing>("body") } // <3>
@ -7602,7 +7602,7 @@ or reactive type such as Reactor `Mono`:
mockMvc.perform(asyncDispatch(mvcResult)) // <4> mockMvc.perform(asyncDispatch(mvcResult)) // <4>
.andExpect { .andExpect {
status().isOk() // <5> status { isOk() } // <5>
content().string("body") content().string("body")
} }
} }