|
1 | 1 | package test.org.springdoc.api.app157;
|
2 | 2 |
|
| 3 | +import java.util.ArrayList; |
| 4 | + |
3 | 5 | import io.swagger.v3.core.converter.ModelConverters;
|
4 |
| -import io.swagger.v3.core.util.Json; |
5 |
| -import org.junit.jupiter.api.AfterAll; |
6 | 6 | import org.junit.jupiter.api.AfterEach;
|
7 |
| -import org.junit.jupiter.api.BeforeAll; |
8 | 7 | import org.junit.jupiter.api.BeforeEach;
|
9 | 8 | import org.junit.jupiter.api.Test;
|
10 | 9 | import org.springdoc.core.Constants;
|
11 |
| -import org.springdoc.core.converters.ModelConverterRegistrar; |
12 |
| -import org.springframework.boot.autoconfigure.SpringBootApplication; |
13 |
| -import org.springframework.test.web.servlet.MvcResult; |
14 | 10 | import test.org.springdoc.api.AbstractSpringDocTest;
|
15 | 11 |
|
16 |
| -import java.util.List; |
| 12 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
17 | 13 |
|
18 |
| -import static org.hamcrest.Matchers.*; |
| 14 | +import static org.hamcrest.Matchers.hasProperty; |
| 15 | +import static org.hamcrest.Matchers.is; |
| 16 | +import static org.hamcrest.Matchers.not; |
19 | 17 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
20 | 18 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
21 | 19 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
27 | 25 | */
|
28 | 26 | public class SpringDocApp157Test extends AbstractSpringDocTest {
|
29 | 27 |
|
30 |
| - @SpringBootApplication |
31 |
| - static class SpringBootApp {} |
32 |
| - |
33 |
| - private StringyConverter myConverter = new StringyConverter(); |
34 |
| - private ModelConverters converters = ModelConverters.getInstance(); |
35 |
| - |
36 |
| - @BeforeEach |
37 |
| - public void registerConverter() { |
38 |
| - converters.addConverter(myConverter); |
39 |
| - } |
40 |
| - |
41 |
| - @AfterEach |
42 |
| - public void unregisterConverter() { |
43 |
| - converters.removeConverter(myConverter); |
44 |
| - } |
45 |
| - |
46 |
| - @Test |
47 |
| - public void testApp() throws Exception { |
48 |
| - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) |
49 |
| - .andExpect(status().isOk()) |
50 |
| - .andExpect(jsonPath("$.openapi", is("3.0.1"))) |
51 |
| - .andExpect(jsonPath("$.components.schemas.Foo.required", is(List.of("stringy")))) |
52 |
| - .andExpect(jsonPath("$.components.schemas.Bar", not(hasProperty("required")))); |
53 |
| - } |
| 28 | + @SpringBootApplication |
| 29 | + static class SpringBootApp {} |
| 30 | + |
| 31 | + private StringyConverter myConverter = new StringyConverter(); |
| 32 | + |
| 33 | + private ModelConverters converters = ModelConverters.getInstance(); |
| 34 | + |
| 35 | + @BeforeEach |
| 36 | + public void registerConverter() { |
| 37 | + converters.addConverter(myConverter); |
| 38 | + } |
| 39 | + |
| 40 | + @AfterEach |
| 41 | + public void unregisterConverter() { |
| 42 | + converters.removeConverter(myConverter); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void testApp() throws Exception { |
| 47 | + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) |
| 48 | + .andExpect(status().isOk()) |
| 49 | + .andExpect(jsonPath("$.openapi", is("3.0.1"))) |
| 50 | + .andExpect(jsonPath("$.components.schemas.Foo.required", is(new ArrayList<String>() {{ |
| 51 | + add("stringy"); |
| 52 | + }}))) |
| 53 | + .andExpect(jsonPath("$.components.schemas.Bar", not(hasProperty("required")))); |
| 54 | + } |
54 | 55 | }
|
0 commit comments