39
39
import org .junit .Test ;
40
40
import org .junit .rules .TemporaryFolder ;
41
41
import org .mockito .Mockito ;
42
+ import org .mockito .invocation .InvocationOnMock ;
43
+ import org .mockito .stubbing .Answer ;
42
44
43
45
import java .io .File ;
44
46
import java .net .URI ;
@@ -55,6 +57,7 @@ public class ROBundleServiceTest {
55
57
56
58
private static ROBundleService roBundleService ;
57
59
private static ROBundleService roBundleServiceZeroSizeLimit ;
60
+ private static Workflow lobSTRdraft3 ;
58
61
59
62
@ Before
60
63
public void setUp () throws Exception {
@@ -103,6 +106,23 @@ public void setUp() throws Exception {
103
106
"CWL Viewer" , "https://view.commonwl.org" , 0 ,
104
107
mockGraphvizService , mockGitService , mockRdfService ,
105
108
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
+ });
106
126
}
107
127
108
128
/**
@@ -117,13 +137,6 @@ public void setUp() throws Exception {
117
137
@ Test
118
138
public void generateAndSaveROBundle () throws Exception {
119
139
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
-
127
140
// RO details
128
141
GitDetails lobSTRdraft3RODetails = new GitDetails ("https://github.com/common-workflow-language/workflows.git" ,
129
142
"933bf2a1a1cce32d88f88f136275535da9df0954" , "lobstr-draft3/" );
@@ -140,12 +153,18 @@ public void generateAndSaveROBundle() throws Exception {
140
153
assertEquals ("CWL Viewer" , manifest .getCreatedBy ().getName ());
141
154
assertEquals ("https://view.commonwl.org" , manifest .getCreatedBy ().getUri ().toString ());
142
155
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 ());
144
160
145
161
// Check cwl aggregation information
162
+ assertEquals (14 , manifest .getAggregates ().size ());
146
163
PathMetadata cwlAggregate = manifest .getAggregation (
147
164
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" ,
149
168
cwlAggregate .getRetrievedFrom ().toString ());
150
169
assertEquals ("Mark Robinson" , cwlAggregate .getAuthoredBy ().get (0 ).getName ());
151
170
assertEquals (
"mailto:[email protected] " ,
cwlAggregate .
getAuthoredBy ().
get (
0 ).
getUri ().
toString ());
@@ -189,13 +208,6 @@ public void generateAndSaveROBundle() throws Exception {
189
208
@ Test
190
209
public void filesOverLimit () throws Exception {
191
210
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
-
199
211
// RO details
200
212
GitDetails lobSTRdraft3RoDetails = new GitDetails ("https://github.com/common-workflow-language/workflows.git" ,
201
213
"933bf2a1a1cce32d88f88f136275535da9df0954" , "lobstr-draft3/" );
0 commit comments