Skip to content

Commit fb914f4

Browse files
committed
Test coverage for WorkflowController generic git
1 parent 7bc2daf commit fb914f4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/test/java/org/commonwl/view/workflow/WorkflowControllerTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
4040
import org.springframework.web.servlet.view.InternalResourceViewResolver;
4141

42+
import java.io.File;
4243
import java.io.IOException;
4344
import java.util.ArrayList;
4445
import java.util.Collections;
@@ -274,8 +275,10 @@ public void downloadROBundle() throws Exception {
274275

275276
// Mock service to return a bundle file and then throw ROBundleNotFoundException
276277
WorkflowService mockWorkflowService = Mockito.mock(WorkflowService.class);
278+
File bundle = roBundleFolder.newFile("bundle.zip").getAbsoluteFile();
277279
when(mockWorkflowService.getROBundle(anyObject()))
278-
.thenReturn(roBundleFolder.newFile("bundle.zip").getAbsoluteFile())
280+
.thenReturn(bundle)
281+
.thenReturn(bundle)
279282
.thenThrow(new ROBundleNotFoundException());
280283

281284
// Mock controller/MVC
@@ -292,6 +295,11 @@ public void downloadROBundle() throws Exception {
292295
.andExpect(status().isOk())
293296
.andExpect(content().contentType("application/vnd.wf4ever.robundle+zip"));
294297

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+
295303
// Bundle does not exist, 404 error
296304
mockMvc.perform(get("/robundle/github.com/owner/repo/blob/branch/path/to/workflow.cwl"))
297305
.andExpect(status().isNotFound());
@@ -307,6 +315,9 @@ public void downloadGraphVizFiles() throws Exception {
307315
// Mock service to return mock workflow
308316
WorkflowService mockWorkflowService = Mockito.mock(WorkflowService.class);
309317
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"))
310321
.thenReturn(new FileSystemResource("src/test/resources/graphviz/testVis.svg"))
311322
.thenReturn(new FileSystemResource("src/test/resources/graphviz/testVis.png"))
312323
.thenReturn(new FileSystemResource("src/test/resources/graphviz/testWorkflow.dot"))
@@ -332,6 +343,17 @@ public void downloadGraphVizFiles() throws Exception {
332343
.andExpect(status().isOk())
333344
.andExpect(content().contentType("text/vnd.graphviz"));
334345

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+
335357
// Images do not exist, 404 error
336358
mockMvc.perform(get("/graph/png/github.com/owner/repo/blob/branch/path/to/workflow.cwl"))
337359
.andExpect(status().isNotFound());

0 commit comments

Comments
 (0)