adding request obj example

This commit is contained in:
John Thompson 2019-05-27 18:17:25 -04:00
parent 520ca97e23
commit 88e356fa6b
No known key found for this signature in database
GPG Key ID: 25C80CE5BD1AF258

View File

@ -24,8 +24,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -82,7 +81,19 @@ class BeerControllerTest {
mockMvc.perform(post("/api/v1/beer/")
.contentType(MediaType.APPLICATION_JSON)
.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