Skip to content

Commit e40bbe0

Browse files
committed
Fix + test for secondaryFiles solo long spec
1 parent 594349b commit e40bbe0

File tree

3 files changed

+111
-25
lines changed

3 files changed

+111
-25
lines changed

src/main/java/org/w3id/cwl/cwl1_2/utils/SecondaryFilesDslLoader.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ public T load(
5151
throw new ValidationException("Expected a string or sequence of (strings or mappings).");
5252
}
5353
}
54+
} else if (doc instanceof Map) {
55+
Map<String, Object> entry = new HashMap<String, Object>();
56+
Map<String, Object> dMap = (Map<String, Object>) doc;
57+
if (dMap.containsKey("pattern")) {
58+
entry.put("pattern", dMap.remove("pattern"));
59+
} else {
60+
throw new ValidationException("Missing 'pattern' in secondaryFiles specification entry.");
61+
}
62+
if (dMap.containsKey("required")) {
63+
entry.put("required", dMap.remove("required"));
64+
}
65+
if (dMap.size() > 0) {
66+
throw new ValidationException("Unallowed values in secondaryFiles specification entry.");
67+
}
68+
r.add(entry);
5469
} else if (doc instanceof String) {
5570
String dString = (String) doc;
5671
Map<String, Object> entry = new HashMap<String, Object>();

src/test/java/org/w3id/cwl/cwl1_2/utils/ExamplesTest.java

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package org.w3id.cwl.cwl1_2.utils;
22

3-
import org.w3id.cwl.cwl1_2.utils.RootLoader;
4-
import org.w3id.cwl.cwl1_2.utils.Uris;
5-
import org.w3id.cwl.cwl1_2.utils.YamlUtils;
6-
73
public class ExamplesTest {
84

95
@org.junit.Test
@@ -890,7 +886,7 @@ public void testvalid_iwdr_entryByMap() throws Exception {
890886
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
891887
RootLoader.loadDocument(doc, url.toString());
892888
}
893-
@org.junit.Test()
889+
@org.junit.Test
894890
public void testvalid_count_lines17_wfByString() throws Exception {
895891
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
896892
String baseUri = Uris.fileUri(path) + "/";
@@ -900,14 +896,14 @@ public void testvalid_count_lines17_wfByString() throws Exception {
900896
RootLoader.loadDocument(yaml, baseUri);
901897
}
902898

903-
@org.junit.Test()
899+
@org.junit.Test
904900
public void testvalid_count_lines17_wfByPath() throws Exception {
905901
java.net.URL url = getClass().getResource("valid_count-lines17-wf.cwl");
906902
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
907903
RootLoader.loadDocument(resPath);
908904
}
909905

910-
@org.junit.Test()
906+
@org.junit.Test
911907
public void testvalid_count_lines17_wfByMap() throws Exception {
912908
java.net.URL url = getClass().getResource("valid_count-lines17-wf.cwl");
913909
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -1020,7 +1016,7 @@ public void testvalid_count_lines2_wfByMap() throws Exception {
10201016
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
10211017
RootLoader.loadDocument(doc, url.toString());
10221018
}
1023-
@org.junit.Test()
1019+
@org.junit.Test
10241020
public void testvalid_count_lines14_wfByString() throws Exception {
10251021
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
10261022
String baseUri = Uris.fileUri(path) + "/";
@@ -1030,14 +1026,14 @@ public void testvalid_count_lines14_wfByString() throws Exception {
10301026
RootLoader.loadDocument(yaml, baseUri);
10311027
}
10321028

1033-
@org.junit.Test()
1029+
@org.junit.Test
10341030
public void testvalid_count_lines14_wfByPath() throws Exception {
10351031
java.net.URL url = getClass().getResource("valid_count-lines14-wf.cwl");
10361032
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
10371033
RootLoader.loadDocument(resPath);
10381034
}
10391035

1040-
@org.junit.Test()
1036+
@org.junit.Test
10411037
public void testvalid_count_lines14_wfByMap() throws Exception {
10421038
java.net.URL url = getClass().getResource("valid_count-lines14-wf.cwl");
10431039
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -1800,7 +1796,7 @@ public void testvalid_inline_jsByMap() throws Exception {
18001796
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
18011797
RootLoader.loadDocument(doc, url.toString());
18021798
}
1803-
@org.junit.Test()
1799+
@org.junit.Test
18041800
public void testvalid_count_lines16_wfByString() throws Exception {
18051801
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
18061802
String baseUri = Uris.fileUri(path) + "/";
@@ -1810,14 +1806,14 @@ public void testvalid_count_lines16_wfByString() throws Exception {
18101806
RootLoader.loadDocument(yaml, baseUri);
18111807
}
18121808

1813-
@org.junit.Test()
1809+
@org.junit.Test
18141810
public void testvalid_count_lines16_wfByPath() throws Exception {
18151811
java.net.URL url = getClass().getResource("valid_count-lines16-wf.cwl");
18161812
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
18171813
RootLoader.loadDocument(resPath);
18181814
}
18191815

1820-
@org.junit.Test()
1816+
@org.junit.Test
18211817
public void testvalid_count_lines16_wfByMap() throws Exception {
18221818
java.net.URL url = getClass().getResource("valid_count-lines16-wf.cwl");
18231819
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -3594,7 +3590,7 @@ public void testvalid_scatter_valuefrom_inputs_wf1ByMap() throws Exception {
35943590
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
35953591
RootLoader.loadDocument(doc, url.toString());
35963592
}
3597-
@org.junit.Test()
3593+
@org.junit.Test
35983594
public void testvalid_count_lines10_wfByString() throws Exception {
35993595
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
36003596
String baseUri = Uris.fileUri(path) + "/";
@@ -3604,14 +3600,14 @@ public void testvalid_count_lines10_wfByString() throws Exception {
36043600
RootLoader.loadDocument(yaml, baseUri);
36053601
}
36063602

3607-
@org.junit.Test()
3603+
@org.junit.Test
36083604
public void testvalid_count_lines10_wfByPath() throws Exception {
36093605
java.net.URL url = getClass().getResource("valid_count-lines10-wf.cwl");
36103606
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
36113607
RootLoader.loadDocument(resPath);
36123608
}
36133609

3614-
@org.junit.Test()
3610+
@org.junit.Test
36153611
public void testvalid_count_lines10_wfByMap() throws Exception {
36163612
java.net.URL url = getClass().getResource("valid_count-lines10-wf.cwl");
36173613
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -3828,6 +3824,7 @@ public void testvalid_wf_loadContentsByMap() throws Exception {
38283824
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
38293825
RootLoader.loadDocument(doc, url.toString());
38303826
}
3827+
38313828
@org.junit.Test
38323829
public void testvalid_record_in_secondaryFilesByString() throws Exception {
38333830
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
@@ -3854,6 +3851,34 @@ public void testvalid_record_in_secondaryFilesByMap() throws Exception {
38543851
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
38553852
RootLoader.loadDocument(doc, url.toString());
38563853
}
3854+
3855+
@org.junit.Test
3856+
public void testvalid_packed_record_in_secondaryFilesByString() throws Exception {
3857+
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
3858+
String baseUri = Uris.fileUri(path) + "/";
3859+
java.net.URL url = getClass().getResource("valid_packed_record-in-secondaryFiles.cwl");
3860+
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
3861+
String yaml = new String(java.nio.file.Files.readAllBytes(resPath), "UTF8");
3862+
RootLoader.loadDocument(yaml, baseUri);
3863+
}
3864+
3865+
@org.junit.Test
3866+
public void testvalid_packed_record_in_secondaryFilesByPath() throws Exception {
3867+
java.net.URL url = getClass().getResource("valid_packed_record-in-secondaryFiles.cwl");
3868+
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
3869+
RootLoader.loadDocument(resPath);
3870+
}
3871+
3872+
@org.junit.Test
3873+
public void testvalid_packed_record_in_secondaryFilesByMap() throws Exception {
3874+
java.net.URL url = getClass().getResource("valid_packed_record-in-secondaryFiles.cwl");
3875+
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
3876+
String yaml = new String(java.nio.file.Files.readAllBytes(resPath), "UTF8");
3877+
java.util.Map<String, Object> doc;
3878+
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
3879+
RootLoader.loadDocument(doc, url.toString());
3880+
}
3881+
38573882
@org.junit.Test
38583883
public void testvalid_writable_dir_dockerByString() throws Exception {
38593884
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
@@ -5128,7 +5153,7 @@ public void testvalid_revsortByMap() throws Exception {
51285153
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
51295154
RootLoader.loadDocument(doc, url.toString());
51305155
}
5131-
@org.junit.Test()
5156+
@org.junit.Test
51325157
public void testvalid_tmap_toolByString() throws Exception {
51335158
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
51345159
String baseUri = Uris.fileUri(path) + "/";
@@ -5138,14 +5163,14 @@ public void testvalid_tmap_toolByString() throws Exception {
51385163
RootLoader.loadDocument(yaml, baseUri);
51395164
}
51405165

5141-
@org.junit.Test()
5166+
@org.junit.Test
51425167
public void testvalid_tmap_toolByPath() throws Exception {
51435168
java.net.URL url = getClass().getResource("valid_tmap-tool.cwl");
51445169
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
51455170
RootLoader.loadDocument(resPath);
51465171
}
51475172

5148-
@org.junit.Test()
5173+
@org.junit.Test
51495174
public void testvalid_tmap_toolByMap() throws Exception {
51505175
java.net.URL url = getClass().getResource("valid_tmap-tool.cwl");
51515176
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -6532,7 +6557,7 @@ public void testvalid_io_int_default_wfByMap() throws Exception {
65326557
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
65336558
RootLoader.loadDocument(doc, url.toString());
65346559
}
6535-
@org.junit.Test()
6560+
@org.junit.Test
65366561
public void testvalid_count_lines18_wfByString() throws Exception {
65376562
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
65386563
String baseUri = Uris.fileUri(path) + "/";
@@ -6542,14 +6567,14 @@ public void testvalid_count_lines18_wfByString() throws Exception {
65426567
RootLoader.loadDocument(yaml, baseUri);
65436568
}
65446569

6545-
@org.junit.Test()
6570+
@org.junit.Test
65466571
public void testvalid_count_lines18_wfByPath() throws Exception {
65476572
java.net.URL url = getClass().getResource("valid_count-lines18-wf.cwl");
65486573
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
65496574
RootLoader.loadDocument(resPath);
65506575
}
65516576

6552-
@org.junit.Test()
6577+
@org.junit.Test
65536578
public void testvalid_count_lines18_wfByMap() throws Exception {
65546579
java.net.URL url = getClass().getResource("valid_count-lines18-wf.cwl");
65556580
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
@@ -6714,7 +6739,7 @@ public void testvalid_rename_outputsByMap() throws Exception {
67146739
doc = (java.util.Map<String, Object>) YamlUtils.mapFromString(yaml);
67156740
RootLoader.loadDocument(doc, url.toString());
67166741
}
6717-
@org.junit.Test()
6742+
@org.junit.Test
67186743
public void testvalid_count_lines15_wfByString() throws Exception {
67196744
String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString();
67206745
String baseUri = Uris.fileUri(path) + "/";
@@ -6724,14 +6749,14 @@ public void testvalid_count_lines15_wfByString() throws Exception {
67246749
RootLoader.loadDocument(yaml, baseUri);
67256750
}
67266751

6727-
@org.junit.Test()
6752+
@org.junit.Test
67286753
public void testvalid_count_lines15_wfByPath() throws Exception {
67296754
java.net.URL url = getClass().getResource("valid_count-lines15-wf.cwl");
67306755
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
67316756
RootLoader.loadDocument(resPath);
67326757
}
67336758

6734-
@org.junit.Test()
6759+
@org.junit.Test
67356760
public void testvalid_count_lines15_wfByMap() throws Exception {
67366761
java.net.URL url = getClass().getResource("valid_count-lines15-wf.cwl");
67376762
java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"class": "CommandLineTool",
3+
"inputs": [
4+
{
5+
"type": {
6+
"type": "record",
7+
"fields": [
8+
{
9+
"type": "File",
10+
"secondaryFiles": {
11+
"pattern": ".s2",
12+
"required": null
13+
},
14+
"name": "#main/record_input/f1"
15+
},
16+
{
17+
"type": {
18+
"type": "array",
19+
"items": "File"
20+
},
21+
"secondaryFiles": {
22+
"pattern": ".s3",
23+
"required": null
24+
},
25+
"name": "#main/record_input/f2"
26+
}
27+
]
28+
},
29+
"id": "#main/record_input"
30+
}
31+
],
32+
"outputs": [],
33+
"baseCommand": "test",
34+
"arguments": [
35+
"-f",
36+
"$(inputs.record_input.f1.path).s2",
37+
"-a",
38+
"-f",
39+
"$(inputs.record_input.f2[0].path).s3",
40+
"-a",
41+
"-f",
42+
"$(inputs.record_input.f2[1].path).s3"
43+
],
44+
"id": "#main",
45+
"cwlVersion": "v1.2"
46+
}

0 commit comments

Comments
 (0)