39
39
import org .springframework .test .web .servlet .setup .MockMvcBuilders ;
40
40
import org .springframework .web .servlet .view .InternalResourceViewResolver ;
41
41
42
+ import java .io .File ;
42
43
import java .io .IOException ;
43
44
import java .util .ArrayList ;
44
45
import java .util .Collections ;
@@ -274,8 +275,10 @@ public void downloadROBundle() throws Exception {
274
275
275
276
// Mock service to return a bundle file and then throw ROBundleNotFoundException
276
277
WorkflowService mockWorkflowService = Mockito .mock (WorkflowService .class );
278
+ File bundle = roBundleFolder .newFile ("bundle.zip" ).getAbsoluteFile ();
277
279
when (mockWorkflowService .getROBundle (anyObject ()))
278
- .thenReturn (roBundleFolder .newFile ("bundle.zip" ).getAbsoluteFile ())
280
+ .thenReturn (bundle )
281
+ .thenReturn (bundle )
279
282
.thenThrow (new ROBundleNotFoundException ());
280
283
281
284
// Mock controller/MVC
@@ -292,6 +295,11 @@ public void downloadROBundle() throws Exception {
292
295
.andExpect (status ().isOk ())
293
296
.andExpect (content ().contentType ("application/vnd.wf4ever.robundle+zip" ));
294
297
298
+ // Generic git and bundle exists
299
+ mockMvc .perform (get ("/robundle/bitbucket.org/owner/repo.git/branch/path/to/workflow.cwl" ))
300
+ .andExpect (status ().isOk ())
301
+ .andExpect (content ().contentType ("application/vnd.wf4ever.robundle+zip" ));
302
+
295
303
// Bundle does not exist, 404 error
296
304
mockMvc .perform (get ("/robundle/github.com/owner/repo/blob/branch/path/to/workflow.cwl" ))
297
305
.andExpect (status ().isNotFound ());
@@ -307,6 +315,9 @@ public void downloadGraphVizFiles() throws Exception {
307
315
// Mock service to return mock workflow
308
316
WorkflowService mockWorkflowService = Mockito .mock (WorkflowService .class );
309
317
when (mockWorkflowService .getWorkflowGraph (anyString (), anyObject ()))
318
+ .thenReturn (new FileSystemResource ("src/test/resources/graphviz/testVis.svg" ))
319
+ .thenReturn (new FileSystemResource ("src/test/resources/graphviz/testVis.png" ))
320
+ .thenReturn (new FileSystemResource ("src/test/resources/graphviz/testWorkflow.dot" ))
310
321
.thenReturn (new FileSystemResource ("src/test/resources/graphviz/testVis.svg" ))
311
322
.thenReturn (new FileSystemResource ("src/test/resources/graphviz/testVis.png" ))
312
323
.thenReturn (new FileSystemResource ("src/test/resources/graphviz/testWorkflow.dot" ))
@@ -332,6 +343,17 @@ public void downloadGraphVizFiles() throws Exception {
332
343
.andExpect (status ().isOk ())
333
344
.andExpect (content ().contentType ("text/vnd.graphviz" ));
334
345
346
+ // Images exist at generic git URLs
347
+ mockMvc .perform (get ("/graph/svg/bitbucket.org/owner/repo.git/branch/path/to/workflow.cwl" ))
348
+ .andExpect (status ().isOk ())
349
+ .andExpect (content ().contentType ("image/svg+xml" ));
350
+ mockMvc .perform (get ("/graph/png/bitbucket.org/owner/repo.git/branch/path/to/workflow.cwl" ))
351
+ .andExpect (status ().isOk ())
352
+ .andExpect (content ().contentType ("image/png" ));
353
+ mockMvc .perform (get ("/graph/xdot/bitbucket.org/owner/repo.git/branch/path/to/workflow.cwl" ))
354
+ .andExpect (status ().isOk ())
355
+ .andExpect (content ().contentType ("text/vnd.graphviz" ));
356
+
335
357
// Images do not exist, 404 error
336
358
mockMvc .perform (get ("/graph/png/github.com/owner/repo/blob/branch/path/to/workflow.cwl" ))
337
359
.andExpect (status ().isNotFound ());
0 commit comments