Skip to content

Commit 6dec561

Browse files
committed
making the test simpler
1 parent 7178378 commit 6dec561

File tree

2 files changed

+130
-24
lines changed

2 files changed

+130
-24
lines changed

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/SpringDocApp143Test.java

-23
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@
1818

1919
package test.org.springdoc.api.app143;
2020

21-
import org.hamcrest.Matchers;
22-
import org.junit.jupiter.api.Assertions;
23-
import org.junit.jupiter.api.Test;
24-
import org.springdoc.core.Constants;
2521
import test.org.springdoc.api.AbstractSpringDocTest;
2622

2723
import org.springframework.boot.autoconfigure.SpringBootApplication;
2824
import org.springframework.test.context.TestPropertySource;
29-
import org.springframework.test.web.servlet.MvcResult;
30-
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
31-
32-
import static org.hamcrest.Matchers.containsString;
33-
import static org.hamcrest.Matchers.is;
34-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
35-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
3625

3726
/**
3827
* Test issue 907 fix.
@@ -44,16 +33,4 @@ public class SpringDocApp143Test extends AbstractSpringDocTest {
4433
@SpringBootApplication
4534
static class SpringDocTestApp {}
4635

47-
@Test
48-
public void testApp() throws Exception {
49-
MvcResult mockMvcResult = mockMvc.perform(MockMvcRequestBuilders.get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk())
50-
.andExpect(jsonPath("$.openapi", is("3.0.1")))
51-
.andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("handle_")))
52-
.andExpect(jsonPath("$.paths./actuator/info.get.summary", Matchers.is("Actuator web endpoint 'info'")))
53-
.andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("handle_")))
54-
.andReturn();
55-
String result = mockMvcResult.getResponse().getContentAsString();
56-
String expected = getContent("results/app143.json");
57-
Assertions.assertEquals(expected, result);
58-
}
5936
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,130 @@
1-
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"tags":[{"name":"Actuator","description":"Monitor and interact","externalDocs":{"description":"Spring Boot Actuator Web API Documentation","url":"https://docs.spring.io/spring-boot/docs/current/actuator-api/html/"}}],"paths":{"/actuator":{"get":{"tags":["Actuator"],"summary":"Actuator root web endpoint","operationId":"links_0","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Link"}}}}}}}}},"/actuator/health":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'health'","operationId":"handle_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},"/actuator/health/**":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'health-path'","operationId":"handle_3","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},"/actuator/info":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'info'","operationId":"handle_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}}},"components":{"schemas":{"Link":{"type":"object","properties":{"href":{"type":"string"},"templated":{"type":"boolean"}}}}}}
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"tags": [
14+
{
15+
"name": "Actuator",
16+
"description": "Monitor and interact",
17+
"externalDocs": {
18+
"description": "Spring Boot Actuator Web API Documentation",
19+
"url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/"
20+
}
21+
}
22+
],
23+
"paths": {
24+
"/actuator": {
25+
"get": {
26+
"tags": [
27+
"Actuator"
28+
],
29+
"summary": "Actuator root web endpoint",
30+
"operationId": "links_0",
31+
"responses": {
32+
"200": {
33+
"description": "OK",
34+
"content": {
35+
"*/*": {
36+
"schema": {
37+
"type": "object",
38+
"additionalProperties": {
39+
"type": "object",
40+
"additionalProperties": {
41+
"$ref": "#/components/schemas/Link"
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}
50+
},
51+
"/actuator/health": {
52+
"get": {
53+
"tags": [
54+
"Actuator"
55+
],
56+
"summary": "Actuator web endpoint 'health'",
57+
"operationId": "handle_2",
58+
"responses": {
59+
"200": {
60+
"description": "OK",
61+
"content": {
62+
"*/*": {
63+
"schema": {
64+
"type": "object"
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
},
72+
"/actuator/health/**": {
73+
"get": {
74+
"tags": [
75+
"Actuator"
76+
],
77+
"summary": "Actuator web endpoint 'health-path'",
78+
"operationId": "handle_3",
79+
"responses": {
80+
"200": {
81+
"description": "OK",
82+
"content": {
83+
"*/*": {
84+
"schema": {
85+
"type": "object"
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
},
93+
"/actuator/info": {
94+
"get": {
95+
"tags": [
96+
"Actuator"
97+
],
98+
"summary": "Actuator web endpoint 'info'",
99+
"operationId": "handle_1",
100+
"responses": {
101+
"200": {
102+
"description": "OK",
103+
"content": {
104+
"*/*": {
105+
"schema": {
106+
"type": "object"
107+
}
108+
}
109+
}
110+
}
111+
}
112+
}
113+
}
114+
},
115+
"components": {
116+
"schemas": {
117+
"Link": {
118+
"type": "object",
119+
"properties": {
120+
"href": {
121+
"type": "string"
122+
},
123+
"templated": {
124+
"type": "boolean"
125+
}
126+
}
127+
}
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)