30
30
import org .commonwl .view .graphviz .GraphVizService ;
31
31
import org .commonwl .view .workflow .Workflow ;
32
32
import org .eclipse .jgit .api .Git ;
33
+ import org .eclipse .jgit .lib .Repository ;
33
34
import org .junit .Before ;
34
35
import org .junit .Rule ;
35
36
import org .junit .Test ;
39
40
import java .io .File ;
40
41
import java .net .URI ;
41
42
import java .nio .file .Path ;
43
+ import java .util .HashSet ;
42
44
import java .util .List ;
45
+ import java .util .Set ;
43
46
44
47
import static org .junit .Assert .*;
45
48
import static org .mockito .Matchers .anyObject ;
@@ -52,7 +55,11 @@ public class ROBundleServiceTest {
52
55
53
56
@ Before
54
57
public void setUp () throws Exception {
55
- gitRepo = Git .open (new File ("src/test/resources/lobstr-draft3" ));
58
+ Repository mockRepo = Mockito .mock (Repository .class );
59
+ when (mockRepo .getWorkTree ()).thenReturn (new File ("src/test/resources/cwl/" ));
60
+
61
+ gitRepo = Mockito .mock (Git .class );
62
+ when (gitRepo .getRepository ()).thenReturn (mockRepo );
56
63
}
57
64
58
65
/**
@@ -62,7 +69,7 @@ public void setUp() throws Exception {
62
69
public TemporaryFolder roBundleFolder = new TemporaryFolder ();
63
70
64
71
/**
65
- * Generate a Research Object bundle from lobstr-v1 and check it
72
+ * Generate a Research Object bundle from lobstr and check it
66
73
*/
67
74
@ Test
68
75
public void generateAndSaveROBundle () throws Exception {
@@ -71,6 +78,11 @@ public void generateAndSaveROBundle() throws Exception {
71
78
GitService mockGitService = Mockito .mock (GitService .class );
72
79
when (mockGitService .getRepository (anyObject ())).thenReturn (gitRepo );
73
80
81
+ Set <HashableAgent > authors = new HashSet <>();
82
+ authors .
add (
new HashableAgent (
"Mark Robinson" ,
null ,
new URI (
"mailto:[email protected] " )));
83
+ when (mockGitService .getAuthors (anyObject (), anyObject ()))
84
+ .thenReturn (authors );
85
+
74
86
// Mock Graphviz service
75
87
GraphVizService mockGraphvizService = Mockito .mock (GraphVizService .class );
76
88
when (mockGraphvizService .getGraph (anyString (), anyString (), anyString ()))
@@ -93,7 +105,7 @@ public void generateAndSaveROBundle() throws Exception {
93
105
94
106
// RO details
95
107
GitDetails lobSTRv1RODetails = new GitDetails ("https://github.com/common-workflow-language/workflows.git" ,
96
- "933bf2a1a1cce32d88f88f136275535da9df0954" , "workflows/lobSTR " );
108
+ "933bf2a1a1cce32d88f88f136275535da9df0954" , "lobstr-draft3/ " );
97
109
98
110
// Create new RO bundle
99
111
ROBundleService bundleService = new ROBundleService (roBundleFolder .getRoot ().toPath (),
@@ -115,12 +127,13 @@ public void generateAndSaveROBundle() throws Exception {
115
127
// Check cwl aggregation information
116
128
PathMetadata cwlAggregate = manifest .getAggregation (
117
129
bundleRoot .resolve ("lobSTR-workflow.cwl" ));
118
- assertEquals ("https://raw.githubusercontent.com/common-workflow-language/workflows/933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR /lobSTR-workflow.cwl" ,
130
+ assertEquals ("https://raw.githubusercontent.com/common-workflow-language/workflows/933bf2a1a1cce32d88f88f136275535da9df0954/lobstr-draft3 /lobSTR-workflow.cwl" ,
119
131
cwlAggregate .getRetrievedFrom ().toString ());
120
132
assertEquals ("Mark Robinson" , cwlAggregate .getAuthoredBy ().get (0 ).getName ());
133
+ assertEquals (
"mailto:[email protected] " ,
cwlAggregate .
getAuthoredBy ().
get (
0 ).
getUri ().
toString ());
121
134
assertNull (cwlAggregate .getAuthoredBy ().get (0 ).getOrcid ());
122
135
assertEquals ("text/x-yaml" , cwlAggregate .getMediatype ());
123
- assertEquals ("https://w3id.org/cwl/v1.0 " , cwlAggregate .getConformsTo ().toString ());
136
+ assertEquals ("https://w3id.org/cwl/draft-3 " , cwlAggregate .getConformsTo ().toString ());
124
137
125
138
// Check visualisations exist as aggregates
126
139
PathMetadata pngAggregate = manifest .getAggregation (bundleRoot .resolve ("visualisation.png" ));
@@ -137,7 +150,7 @@ public void generateAndSaveROBundle() throws Exception {
137
150
// Check git2prov link is in the history
138
151
List <Path > history = manifest .getHistory ();
139
152
assertEquals (1 , history .size ());
140
- assertEquals ("http:/git2prov.org/git2prov?giturl=https:/github.com/common-workflow-language/workflows&serialization=PROV-JSON" ,
153
+ assertEquals ("http:/git2prov.org/git2prov?giturl=https:/github.com/common-workflow-language/workflows.git &serialization=PROV-JSON" ,
141
154
history .get (0 ).toString ());
142
155
143
156
// Save and check it exists in the temporary folder
@@ -162,6 +175,11 @@ public void filesOverLimit() throws Exception {
162
175
GitService mockGitService = Mockito .mock (GitService .class );
163
176
when (mockGitService .getRepository (anyObject ())).thenReturn (gitRepo );
164
177
178
+ Set <HashableAgent > authors = new HashSet <>();
179
+ authors .
add (
new HashableAgent (
"Mark Robinson" ,
null ,
new URI (
"mailto:[email protected] " )));
180
+ when (mockGitService .getAuthors (anyObject (), anyObject ()))
181
+ .thenReturn (authors );
182
+
165
183
// Mock Graphviz service
166
184
GraphVizService mockGraphvizService = Mockito .mock (GraphVizService .class );
167
185
when (mockGraphvizService .getGraph (anyString (), anyString (), anyString ()))
@@ -184,7 +202,7 @@ public void filesOverLimit() throws Exception {
184
202
185
203
// RO details
186
204
GitDetails lobSTRv1RODetails = new GitDetails ("https://github.com/common-workflow-language/workflows.git" ,
187
- "933bf2a1a1cce32d88f88f136275535da9df0954" , "workflows /lobSTR" );
205
+ "933bf2a1a1cce32d88f88f136275535da9df0954" , "lobstr-draft3 /lobSTR-workflow.cwl " );
188
206
189
207
// Create new RO bundle
190
208
ROBundleService bundleService = new ROBundleService (roBundleFolder .getRoot ().toPath (),
@@ -198,9 +216,7 @@ public void filesOverLimit() throws Exception {
198
216
assertEquals (14 , manifest .getAggregates ().size ());
199
217
200
218
PathMetadata urlAggregate = manifest .getAggregation (
201
- new URI ("https://raw.githubusercontent.com/common-workflow-language/workflows/" +
202
- "933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/models/" +
203
- "illumina_v3.pcrfree.stepmodel" ));
219
+ new URI ("https://raw.githubusercontent.com/common-workflow-language/workflows/933bf2a1a1cce32d88f88f136275535da9df0954/lobstr-draft3/lobSTR-workflow.cwl/models/illumina_v3.pcrfree.stepmodel" ));
204
220
assertEquals ("Mark Robinson" , urlAggregate .getAuthoredBy ().get (0 ).getName ());
205
221
206
222
}
0 commit comments