adding query param example

This commit is contained in:
John Thompson 2019-05-27 17:36:59 -04:00
parent 40a65b05f2
commit cd16adf327
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.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.restdocs.request.RequestDocumentation.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@ -49,11 +48,17 @@ class BeerControllerTest {
void getBeerById() throws Exception {
given(beerRepository.findById(any())).willReturn(Optional.of(Beer.builder().build()));
mockMvc.perform(get("/api/v1/beer/{beerId}", UUID.randomUUID().toString()).accept(MediaType.APPLICATION_JSON))
mockMvc.perform(get("/api/v1/beer/{beerId}", UUID.randomUUID().toString())
.param("iscold", "yes")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("v1/beer", pathParameters(
parameterWithName("beerId").description("UUID of desired beer to get.")
)));
.andDo(document("v1/beer",
pathParameters (
parameterWithName("beerId").description("UUID of desired beer to get.")
),
requestParameters(
parameterWithName("iscold").description("Is Beer Cold Query param")
)));
}
@Test