Skip to content

Commit b1fbe33

Browse files
committed
Mock rdfService for RO bundle testing
1 parent a9859bc commit b1fbe33

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/test/java/org/commonwl/view/researchobject/ROBundleServiceTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.commonwl.view.researchobject;
2121

22+
import org.apache.jena.query.ResultSet;
2223
import org.apache.taverna.robundle.Bundle;
2324
import org.apache.taverna.robundle.Bundles;
2425
import org.apache.taverna.robundle.manifest.Manifest;
@@ -97,6 +98,12 @@ public void generateAndSaveROBundle() throws Exception {
9798
when(mockCwlTool.getRDF(anyString()))
9899
.thenReturn("@prefix cwl: <https://w3id.org/cwl/cwl#> .");
99100

101+
// Mock RDF Service
102+
ResultSet emptyResult = Mockito.mock(ResultSet.class);
103+
when(emptyResult.hasNext()).thenReturn(false);
104+
RDFService mockRdfService = Mockito.mock(RDFService.class);
105+
when(mockRdfService.getAuthors(anyString(), anyString())).thenReturn(emptyResult);
106+
100107
// Workflow details
101108
GitDetails lobSTRv1Details = new GitDetails("https://github.com/common-workflow-language/workflows.git",
102109
"933bf2a1a1cce32d88f88f136275535da9df0954", "workflows/lobSTR/lobSTR-workflow.cwl");
@@ -111,7 +118,7 @@ public void generateAndSaveROBundle() throws Exception {
111118
// Create new RO bundle
112119
ROBundleService bundleService = new ROBundleService(roBundleFolder.getRoot().toPath(),
113120
"CWL Viewer", "https://view.commonwl.org", 5242880,
114-
mockGraphvizService, mockGitService, Mockito.mock(RDFService.class), mockCwlTool);
121+
mockGraphvizService, mockGitService, mockRdfService, mockCwlTool);
115122
Bundle bundle = bundleService.createBundle(lobSTRv1, lobSTRv1RODetails);
116123
Path bundleRoot = bundle.getRoot().resolve("workflow");
117124

@@ -194,6 +201,12 @@ public void filesOverLimit() throws Exception {
194201
when(mockCwlTool.getRDF(anyString()))
195202
.thenReturn("@prefix cwl: <https://w3id.org/cwl/cwl#> .");
196203

204+
// Mock RDF Service
205+
ResultSet emptyResult = Mockito.mock(ResultSet.class);
206+
when(emptyResult.hasNext()).thenReturn(false);
207+
RDFService mockRdfService = Mockito.mock(RDFService.class);
208+
when(mockRdfService.getAuthors(anyString(), anyString())).thenReturn(emptyResult);
209+
197210
// Workflow details
198211
GitDetails lobSTRv1Details = new GitDetails("https://github.com/common-workflow-language/workflows.git",
199212
"933bf2a1a1cce32d88f88f136275535da9df0954", "workflows/lobSTR/lobSTR-workflow.cwl");
@@ -208,7 +221,7 @@ public void filesOverLimit() throws Exception {
208221
// Create new RO bundle
209222
ROBundleService bundleService = new ROBundleService(roBundleFolder.getRoot().toPath(),
210223
"CWL Viewer", "https://view.commonwl.org", 0, mockGraphvizService,
211-
mockGitService, Mockito.mock(RDFService.class), mockCwlTool);
224+
mockGitService, mockRdfService, mockCwlTool);
212225
Bundle bundle = bundleService.createBundle(lobSTRv1, lobSTRv1RODetails);
213226

214227
Manifest manifest = bundle.getManifest();

0 commit comments

Comments
 (0)