11package test .org .springdoc .api .app4 ;
22
3- import static org .hamcrest .Matchers .*;
4- import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .*;
5- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .*;
3+ import test .org .springdoc .api .AbstractSpringDocTest ;
64
7- import org .hamcrest .Matchers ;
8- import org .junit .Test ;
9- import org .junit .runner .RunWith ;
10- import org .springdoc .core .Constants ;
11- import org .springframework .beans .factory .annotation .Autowired ;
12- import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
13- import org .springframework .boot .test .context .SpringBootTest ;
14- import org .springframework .test .context .ActiveProfiles ;
15- import org .springframework .test .context .junit4 .SpringRunner ;
16- import org .springframework .test .web .servlet .MockMvc ;
5+ public class SpringDocApp4Test extends AbstractSpringDocTest {
176
18- @ RunWith (SpringRunner .class )
19- @ SpringBootTest
20- @ ActiveProfiles ("test" )
21- @ AutoConfigureMockMvc
22- public class SpringDocApp4Test {
237
24- @ Autowired
25- private MockMvc mockMvc ;
26-
27- @ Test
28- public void testApp4 () throws Exception {
29- mockMvc .perform (get (Constants .DEFAULT_API_DOCS_URL )).andExpect (status ().isOk ())
30- .andExpect (jsonPath ("$.openapi" , is ("3.0.1" )))
31- .andExpect (jsonPath ("$.info.title" , is ("OpenAPI definition" )))
32- .andExpect (jsonPath ("$.info.version" , is ("v0" )))
33- .andExpect (jsonPath ("$.paths./values/data.post.operationId" , is ("list" )))
34- .andExpect (jsonPath ("$.paths./values/data.post.requestBody.content.['*/*'].schema.['$ref']" ,
35- is ("#/components/schemas/TrackerData" )))
36- .andExpect (jsonPath ("$.paths./values/data.post.responses.200.content.['*/*'].schema.['$ref']" ,
37- is ("#/components/schemas/TrackerData" )))
38- .andExpect (
39- jsonPath ("$.paths./values/data.post.responses.200.description" , is ("default response" )))
40- .andExpect (jsonPath ("$.components.schemas.TrackerData.required" )
41- .value (Matchers .containsInAnyOrder ("timestamp" , "trackerId" , "value" )))
42- .andExpect (jsonPath ("$.components.schemas.TrackerData.type" , is ("object" )))
43- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.trackerId.type" , is ("string" )))
44- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.timestamp.type" , is ("string" )))
45- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.value.type" , is ("number" )))
46- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.timestamp.format" , is ("date-time" )))
47- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.value.format" , is ("double" )))
48- .andExpect (
49- jsonPath ("$.components.schemas.TrackerData.properties.trackerId.example" , is ("the-tracker-id" )))
50- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.timestamp.example" ,
51- is ("2018-01-01T00:00:00Z" )))
52- .andExpect (jsonPath ("$.components.schemas.TrackerData.properties.value.example" , is (19.0 )));
53- }
54-
55- }
8+ }
0 commit comments