Skip to content

Commit ef8a9d2

Browse files
committed
Add unit tests
1 parent 79c6168 commit ef8a9d2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package test.org.springdoc.api.app68;
22

3+
import org.hamcrest.Matchers;
34
import org.junit.Test;
45
import org.junit.runner.RunWith;
56
import org.slf4j.Logger;
@@ -13,10 +14,14 @@
1314
import org.springframework.test.web.servlet.MockMvc;
1415
import test.org.springdoc.api.AbstractSpringDocTest;
1516

17+
import static org.hamcrest.Matchers.contains;
1618
import static org.hamcrest.Matchers.containsString;
19+
import static org.hamcrest.Matchers.hasSize;
1720
import static org.hamcrest.Matchers.is;
1821
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
19-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
22+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
23+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
24+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
2025
import static test.org.springdoc.utils.FileUtils.getContent;
2126

2227
@RunWith(SpringRunner.class)
@@ -67,6 +72,20 @@ public void testApp4() throws Exception {
6772
@Test
6873
public void testActuator() throws Exception {
6974
mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk())
70-
.andExpect(jsonPath("$.openapi", is("3.0.1"))).andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("handle"))).andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("handle")));
75+
.andExpect(jsonPath("$.openapi", is("3.0.1")))
76+
.andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("handle_")))
77+
.andExpect(jsonPath("$.paths./actuator/info.get.summary", Matchers.is("Actuator web endpoint 'info'")))
78+
.andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("handle_")));
79+
}
80+
81+
@Test
82+
public void testActuatorDescription() throws Exception {
83+
mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk())
84+
.andExpect(jsonPath("$.openapi", is("3.0.1")))
85+
.andExpect(jsonPath("$.tags", hasSize(4)))
86+
.andExpect(jsonPath("$.tags[?(@.name == '"+Constants.SPRINGDOC_ACTUATOR_TAG+"')].name", contains(Constants.SPRINGDOC_ACTUATOR_TAG)))
87+
.andExpect(jsonPath("$.tags[?(@.name == '"+Constants.SPRINGDOC_ACTUATOR_TAG+"')].description", contains(Constants.SPRINGDOC_ACTUATOR_DESCRIPTION)))
88+
.andExpect(jsonPath("$.tags[?(@.name == '"+Constants.SPRINGDOC_ACTUATOR_TAG+"')].externalDocs.description", contains(Constants.SPRINGDOC_ACTUATOR_DOC_DESCRIPTION)))
89+
.andExpect(jsonPath("$.tags[?(@.name == '"+Constants.SPRINGDOC_ACTUATOR_TAG+"')].externalDocs.url", contains(Constants.SPRINGDOC_ACTUATOR_DOC_URL)));
7190
}
7291
}

0 commit comments

Comments
 (0)