• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

common-workflow-language / cwljava / #389

30 Oct 2025 05:13PM UTC coverage: 58.693% (-0.8%) from 59.538%
#389

Pull #218

github

web-flow
Merge 98b159202 into befd7e4b9
Pull Request #218: Populate the extensionFields; add public accessors for LoadingOptions

230 of 569 new or added lines in 67 files covered. (40.42%)

28 existing lines in 27 files now uncovered.

7535 of 12838 relevant lines covered (58.69%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.63
/src/main/java/org/w3id/cwl/cwl1_2/utils/LoadingOptions.java
1
package org.w3id.cwl.cwl1_2.utils;
2

3
import java.net.URI;
4
import java.util.ArrayList;
5
import java.util.Arrays;
6
import java.util.List;
7
import java.util.Map;
8

9
public class LoadingOptions {
10
  Fetcher fetcher;
11
  String fileUri;
12
  Map<String, String> namespaces;
13
  List<String> schemas;
14
  Boolean noLinkCheck;
15
  String container;
16
  Map<String, Object> idx;
17
  Map<String, String> vocab;
18
  Map<String, String> rvocab;
19

20
  LoadingOptions(
21
      final Fetcher fetcher,
22
      final String fileUri,
23
      final Map<String, String> namespaces,
24
      final List<String> schemas,
25
      final Boolean noLinkCheck,
26
      final String container,
27
      final Map<String, Object> idx) {
1✔
28
    this.fetcher = fetcher;
1✔
29
    this.fileUri = fileUri;
1✔
30
    this.namespaces = namespaces;
1✔
31
    this.schemas = schemas;
1✔
32
    this.noLinkCheck = noLinkCheck;
1✔
33
    this.container = container;
1✔
34
    this.idx = idx;
1✔
35

36
    if (namespaces != null) {
1✔
37
      this.vocab = (Map<String, String>) ConstantMaps.vocab.clone();
1✔
38
      this.rvocab = (Map<String, String>) ConstantMaps.rvocab.clone();
1✔
39
      for (Map.Entry<String, String> namespaceEntry : namespaces.entrySet()) {
1✔
40
        this.vocab.put(namespaceEntry.getKey(), namespaceEntry.getValue());
1✔
41
        this.rvocab.put(namespaceEntry.getValue(), namespaceEntry.getKey());
1✔
42
      }
1✔
43
    } else {
44
      this.vocab = (Map<String, String>) ConstantMaps.vocab;
1✔
45
      this.rvocab = (Map<String, String>) ConstantMaps.rvocab;
1✔
46
    }
47
  }
1✔
48

49
  public String expandUrl(
50
      String url_,
51
      final String baseUrl,
52
      final boolean scopedId,
53
      final boolean vocabTerm,
54
      final Integer scopedRef) {
55
    // NOT CONVERTING this - doesn't match type declaration
56
    // if not isinstance(url, str):
57
    //    return url
58
    String url = url_;
1✔
59
    if (url.equals("@id") || url.equals("@type")) {
1✔
60
      return url;
×
61
    }
62

63
    if (vocabTerm && this.vocab.containsKey(url)) {
1✔
64
      return url;
1✔
65
    }
66

67
    if (!this.vocab.isEmpty() && url.contains(":")) {
1✔
68
      String prefix = url.split(":")[0];
1✔
69
      if (this.vocab.containsKey(prefix)) {
1✔
70
        url = this.vocab.get(prefix) + url.substring(prefix.length() + 1);
1✔
71
      }
72
    }
73

74
    Uris.UriSplit split = Uris.split(url);
1✔
75
    final String scheme = split.scheme;
1✔
76
    final boolean hasFragment = stringHasContent(split.fragment);
1✔
77
    if (scheme != null
1✔
78
        && ((scheme.length() > 0
1✔
79
                && (scheme.equals("http") || scheme.equals("https") || scheme.equals("file")))
1✔
UNCOV
80
            || url.startsWith("$(")
×
UNCOV
81
            || url.startsWith("${"))) {
×
82
      // pass
83
    } else if (scopedId && !hasFragment) {
1✔
84
      final Uris.UriSplit splitbase = Uris.split(baseUrl);
1✔
85
      final String frg;
86
      if (stringHasContent(splitbase.fragment)) {
1✔
87
        frg = splitbase.fragment + "/" + split.path;
1✔
88
      } else {
89
        frg = split.path;
1✔
90
      }
91
      String pt;
92
      if (!splitbase.path.equals("")) {
1✔
93
        pt = splitbase.path;
1✔
94
      } else {
95
        pt = "/";
×
96
      }
97
      url = Uris.unsplit(splitbase.scheme, splitbase.netloc, pt, splitbase.query, frg);
1✔
98
    } else if (scopedRef != null && !hasFragment) {
1✔
99
      final Uris.UriSplit splitbase = Uris.split(baseUrl);
1✔
100
      final ArrayList<String> sp = new ArrayList(Arrays.asList(splitbase.fragment.split("/")));
1✔
101
      int n = scopedRef;
1✔
102
      while (n > 0 && sp.size() > 0) {
1✔
103
        sp.remove(sp.size()-1);
1✔
104
        n -= 1;
1✔
105
      }
106
      sp.add(url);
1✔
107
      final String fragment = String.join("/", sp);
1✔
108
      url = Uris.unsplit(splitbase.scheme, splitbase.netloc, splitbase.path, splitbase.query, fragment);
1✔
109
    } else {
1✔
110
      url = this.fetcher.urlJoin(baseUrl, url);
1✔
111
    }
112

113
    if (vocabTerm) {
1✔
114
      split = Uris.split(url);
1✔
115
      if (stringHasContent(split.scheme)) {
1✔
116
        if (this.rvocab.containsKey(url)) {
1✔
117
          return this.rvocab.get(url);
×
118
        }
119
      } else {
120
        throw new ValidationException("Term '{}' not in vocabulary".format(url));
×
121
      }
122
    }
123
    return url;
1✔
124
  }
125

126
  static boolean stringHasContent(final String s) {
127
    return s != null && s.length() > 0;
1✔
128
  }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc