mirror of
https://github.com/robindhole/sfg-restdocs-example.git
synced 2025-03-16 08:20:01 +00:00
adding request obj example
This commit is contained in:
parent
520ca97e23
commit
88e356fa6b
@ -24,8 +24,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
|
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
|
||||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
|
||||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
|
||||||
import static org.springframework.restdocs.request.RequestDocumentation.*;
|
import static org.springframework.restdocs.request.RequestDocumentation.*;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@ -82,7 +81,19 @@ class BeerControllerTest {
|
|||||||
mockMvc.perform(post("/api/v1/beer/")
|
mockMvc.perform(post("/api/v1/beer/")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(beerDtoJson))
|
.content(beerDtoJson))
|
||||||
.andExpect(status().isCreated());
|
.andExpect(status().isCreated())
|
||||||
|
.andDo(document("v1/beer",
|
||||||
|
requestFields(
|
||||||
|
fieldWithPath("id").ignored(),
|
||||||
|
fieldWithPath("version").ignored(),
|
||||||
|
fieldWithPath("createdDate").ignored(),
|
||||||
|
fieldWithPath("lastModifiedDate").ignored(),
|
||||||
|
fieldWithPath("beerName").description("Name of the beer"),
|
||||||
|
fieldWithPath("beerStyle").description("Style of Beer"),
|
||||||
|
fieldWithPath("upc").description("Beer UPC").attributes(),
|
||||||
|
fieldWithPath("price").description("Beer Price"),
|
||||||
|
fieldWithPath("quantityOnHand").ignored()
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user