68
68
import org .junit .Test ;
69
69
import org .junit .runner .RunWith ;
70
70
import org .springframework .beans .factory .annotation .Autowired ;
71
- import org .springframework .boot .test .autoconfigure .restdocs .RestDocsMockMvcConfigurationCustomizer ;
72
71
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
73
72
import org .springframework .boot .test .context .SpringBootTest ;
74
- import org .springframework .boot .test .context .TestConfiguration ;
75
- import org .springframework .context .annotation .Bean ;
76
73
import org .springframework .data .domain .PageRequest ;
77
74
import org .springframework .http .HttpHeaders ;
78
75
import org .springframework .http .MediaType ;
79
76
import org .springframework .http .converter .json .Jackson2ObjectMapperBuilder ;
80
77
import org .springframework .mock .web .MockHttpServletResponse ;
81
78
import org .springframework .mock .web .MockMultipartFile ;
82
- import org .springframework .restdocs .mockmvc .MockMvcRestDocumentationConfigurer ;
83
- import org .springframework .restdocs .templates .TemplateFormats ;
84
79
import org .springframework .security .test .context .support .WithSecurityContextTestExecutionListener ;
85
80
import org .springframework .test .context .ActiveProfiles ;
86
81
import org .springframework .test .context .TestExecutionListeners ;
@@ -146,7 +141,7 @@ public class DataResourceControllerTest {
146
141
private DataResource otherResource ;
147
142
private DataResource revokedResource ;
148
143
private DataResource fixedResource ;
149
-
144
+
150
145
@ Before
151
146
public void setUp () throws JsonProcessingException {
152
147
contentInformationAuditService = repositoryConfig .getContentInformationAuditService ();
@@ -1793,10 +1788,10 @@ public void testCreateGetDeleteOfContentWithVersion() throws Exception {
1793
1788
this .mockMvc .perform (get ("/api/v1/audit/" + resourceId + "/data/file.txt" ).header (HttpHeaders .AUTHORIZATION ,
1794
1789
"Bearer " + userToken ).header (HttpHeaders .ACCEPT , "application/vnd.datamanager.audit+json" )).andDo (print ()).andExpect (status ().isOk ()).andExpect (MockMvcResultMatchers .header ().exists ("Resource-Version" )).andExpect (MockMvcResultMatchers .header ().string ("Resource-Version" , "2" ));
1795
1790
1796
- //get ETag
1791
+ //get ETag
1797
1792
etag = this .mockMvc .perform (get ("/api/v1/dataresources/" + resourceId + "/data/file.txt" ).header (HttpHeaders .AUTHORIZATION ,
1798
1793
"Bearer " + userToken ).header (HttpHeaders .ACCEPT , "application/vnd.datamanager.content-information+json" )).andDo (print ()).andExpect (status ().isOk ()).andExpect (MockMvcResultMatchers .jsonPath ("$.tags[0]" ).value ("success" )).andReturn ().getResponse ().getHeader ("ETag" );
1799
-
1794
+
1800
1795
//delete content
1801
1796
this .mockMvc .perform (delete ("/api/v1/dataresources/" + resourceId + "/data/file.txt" ).header (HttpHeaders .AUTHORIZATION ,
1802
1797
"Bearer " + userToken ).header ("If-Match" , etag ).header (HttpHeaders .ACCEPT , "application/vnd.datamanager.content-information+json" )).andDo (print ()).andExpect (status ().isNoContent ());
@@ -1808,6 +1803,16 @@ public void testCreateGetDeleteOfContentWithVersion() throws Exception {
1808
1803
"Bearer " + userToken ).header (HttpHeaders .ACCEPT , "application/vnd.datamanager.content-information+json" )).andDo (print ()).andExpect (status ().isNotFound ());
1809
1804
}
1810
1805
1806
+ @ Test
1807
+ public void testSwaggerUI () throws Exception {
1808
+
1809
+ // Test for swagger definition
1810
+ this .mockMvc .perform (get ("/v3/api-docs" ))
1811
+ .andDo (print ())
1812
+ .andExpect (status ().isOk ())
1813
+ .andExpect (MockMvcResultMatchers .jsonPath ("$.info.title" , Matchers .startsWith ("Repository" )));
1814
+ }
1815
+
1811
1816
// @Test
1812
1817
// public void testObtainHealthInformation() throws Exception{
1813
1818
// this.mockMvc.perform(get("/actuator/health")).andDo(print()).andExpect(status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.status").value("UP"));
0 commit comments