Skip to content

Commit 0aeec6a

Browse files
committed
Test for permalinks in RO and RDF
1 parent acebcde commit 0aeec6a

File tree

3 files changed

+78
-66
lines changed

3 files changed

+78
-66
lines changed

src/test/java/org/commonwl/view/cwl/CWLServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void setUp() throws Exception {
6464
Model workflowModel = ModelFactory.createDefaultModel();
6565
workflowModel.read(new ByteArrayInputStream(readFileToString(packedWorkflowRdf).getBytes()), null, "TURTLE");
6666
Dataset workflowDataset = DatasetFactory.create();
67-
workflowDataset.addNamedModel("http://localhost:3030/cwlviewer/github.com/common-workflow-language/workflows/blob/549c973ccc01781595ce562dea4cedc6c9540fe0/workflows/make-to-cwl/dna.cwl#main", workflowModel);
67+
workflowDataset.addNamedModel("https://w3id.org/cwl/view/git/549c973ccc01781595ce562dea4cedc6c9540fe0/workflows/make-to-cwl/dna.cwl#main", workflowModel);
6868

6969
Answer queryRdf = new Answer<ResultSet>() {
7070
@Override

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

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.junit.Test;
4040
import org.junit.rules.TemporaryFolder;
4141
import org.mockito.Mockito;
42+
import org.mockito.invocation.InvocationOnMock;
43+
import org.mockito.stubbing.Answer;
4244

4345
import java.io.File;
4446
import java.net.URI;
@@ -55,6 +57,7 @@ public class ROBundleServiceTest {
5557

5658
private static ROBundleService roBundleService;
5759
private static ROBundleService roBundleServiceZeroSizeLimit;
60+
private static Workflow lobSTRdraft3;
5861

5962
@Before
6063
public void setUp() throws Exception {
@@ -103,6 +106,23 @@ public void setUp() throws Exception {
103106
"CWL Viewer", "https://view.commonwl.org", 0,
104107
mockGraphvizService, mockGitService, mockRdfService,
105108
Mockito.mock(GitSemaphore.class), mockCwlTool);
109+
110+
GitDetails lobSTRdraft3Details = new GitDetails("https://github.com/common-workflow-language/workflows.git",
111+
"933bf2a1a1cce32d88f88f136275535da9df0954", "workflows/lobSTR/lobSTR-workflow.cwl");
112+
lobSTRdraft3 = Mockito.mock(Workflow.class);
113+
when(lobSTRdraft3.getID()).thenReturn("testID");
114+
when(lobSTRdraft3.getRetrievedFrom()).thenReturn(lobSTRdraft3Details);
115+
when(lobSTRdraft3.getLastCommit()).thenReturn("933bf2a1a1cce32d88f88f136275535da9df0954");
116+
when(lobSTRdraft3.getPermalink()).thenReturn("https://w3id.org/cwl/view/git/" +
117+
"933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/lobSTR-workflow.cwl");
118+
when(lobSTRdraft3.getPermalink(anyString())).thenAnswer(new Answer<String>() {
119+
@Override
120+
public String answer(InvocationOnMock invocation) throws Throwable {
121+
Object[] args = invocation.getArguments();
122+
return "https://w3id.org/cwl/view/git/933bf2a1a1cce32d88f88f136275535da9df0954/" +
123+
"workflows/lobSTR/lobSTR-workflow.cwl?format=" + args[0];
124+
}
125+
});
106126
}
107127

108128
/**
@@ -117,13 +137,6 @@ public void setUp() throws Exception {
117137
@Test
118138
public void generateAndSaveROBundle() throws Exception {
119139

120-
// Workflow details
121-
GitDetails lobSTRdraft3Details = new GitDetails("https://github.com/common-workflow-language/workflows.git",
122-
"933bf2a1a1cce32d88f88f136275535da9df0954", "workflows/lobSTR/lobSTR-workflow.cwl");
123-
Workflow lobSTRdraft3 = Mockito.mock(Workflow.class);
124-
when(lobSTRdraft3.getID()).thenReturn("testID");
125-
when(lobSTRdraft3.getRetrievedFrom()).thenReturn(lobSTRdraft3Details);
126-
127140
// RO details
128141
GitDetails lobSTRdraft3RODetails = new GitDetails("https://github.com/common-workflow-language/workflows.git",
129142
"933bf2a1a1cce32d88f88f136275535da9df0954", "lobstr-draft3/");
@@ -140,12 +153,18 @@ public void generateAndSaveROBundle() throws Exception {
140153
assertEquals("CWL Viewer", manifest.getCreatedBy().getName());
141154
assertEquals("https://view.commonwl.org", manifest.getCreatedBy().getUri().toString());
142155
assertEquals("Mark Robinson", manifest.getAuthoredBy().get(0).getName());
143-
assertEquals(14, manifest.getAggregates().size());
156+
assertEquals(new URI("https://w3id.org/cwl/view/git/933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/lobSTR-workflow.cwl"),
157+
manifest.getId());
158+
assertEquals(new URI("https://w3id.org/cwl/view/git/933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/lobSTR-workflow.cwl?format=ro"),
159+
manifest.getRetrievedFrom());
144160

145161
// Check cwl aggregation information
162+
assertEquals(14, manifest.getAggregates().size());
146163
PathMetadata cwlAggregate = manifest.getAggregation(
147164
bundleRoot.resolve("lobSTR-workflow.cwl"));
148-
assertEquals("https://w3id.org/cwl/view/git/null/lobstr-draft3/lobSTR-workflow.cwl?format=raw",
165+
// NOTE: This permalink is based on local folder structure, here in tests
166+
// it is slightly different but normally would not be
167+
assertEquals("https://w3id.org/cwl/view/git/933bf2a1a1cce32d88f88f136275535da9df0954/lobstr-draft3/lobSTR-workflow.cwl?format=raw",
149168
cwlAggregate.getRetrievedFrom().toString());
150169
assertEquals("Mark Robinson", cwlAggregate.getAuthoredBy().get(0).getName());
151170
assertEquals("mailto:[email protected]", cwlAggregate.getAuthoredBy().get(0).getUri().toString());
@@ -189,13 +208,6 @@ public void generateAndSaveROBundle() throws Exception {
189208
@Test
190209
public void filesOverLimit() throws Exception {
191210

192-
// Workflow details
193-
GitDetails lobSTRdraft3Details = new GitDetails("https://github.com/common-workflow-language/workflows.git",
194-
"933bf2a1a1cce32d88f88f136275535da9df0954", "workflows/lobSTR/lobSTR-workflow.cwl");
195-
Workflow lobSTRdraft3 = Mockito.mock(Workflow.class);
196-
when(lobSTRdraft3.getID()).thenReturn("testID");
197-
when(lobSTRdraft3.getRetrievedFrom()).thenReturn(lobSTRdraft3Details);
198-
199211
// RO details
200212
GitDetails lobSTRdraft3RoDetails = new GitDetails("https://github.com/common-workflow-language/workflows.git",
201213
"933bf2a1a1cce32d88f88f136275535da9df0954", "lobstr-draft3/");

0 commit comments

Comments
 (0)