mirror of
https://github.com/robindhole/sfg-restdocs-example.git
synced 2025-03-15 23:29:55 +00:00
adding query param example
This commit is contained in:
parent
40a65b05f2
commit
cd16adf327
@ -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,10 +48,16 @@ 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(
|
||||
.andDo(document("v1/beer",
|
||||
pathParameters (
|
||||
parameterWithName("beerId").description("UUID of desired beer to get.")
|
||||
),
|
||||
requestParameters(
|
||||
parameterWithName("iscold").description("Is Beer Cold Query param")
|
||||
)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user