mirror of
https://github.com/robindhole/sfg-restdocs-example.git
synced 2025-03-15 19:50:01 +00:00
adding path param example
This commit is contained in:
parent
5dbf86e457
commit
40a65b05f2
@ -22,9 +22,14 @@ import java.util.UUID;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
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.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
//import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
@ExtendWith(RestDocumentationExtension.class)
|
||||
@AutoConfigureRestDocs
|
||||
@WebMvcTest(BeerController.class)
|
||||
@ -44,8 +49,11 @@ class BeerControllerTest {
|
||||
void getBeerById() throws Exception {
|
||||
given(beerRepository.findById(any())).willReturn(Optional.of(Beer.builder().build()));
|
||||
|
||||
mockMvc.perform(get("/api/v1/beer/" + UUID.randomUUID().toString()).accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
mockMvc.perform(get("/api/v1/beer/{beerId}", UUID.randomUUID().toString()).accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("v1/beer", pathParameters(
|
||||
parameterWithName("beerId").description("UUID of desired beer to get.")
|
||||
)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user