1919
2020package org .commonwl .view .cwl ;
2121
22- import org .apache .jena .query .*;
22+ import org .apache .jena .query .Dataset ;
23+ import org .apache .jena .query .DatasetFactory ;
24+ import org .apache .jena .query .Query ;
25+ import org .apache .jena .query .QueryExecution ;
26+ import org .apache .jena .query .QueryExecutionFactory ;
27+ import org .apache .jena .query .QueryFactory ;
28+ import org .apache .jena .query .ResultSet ;
29+ import org .apache .jena .query .ResultSetFactory ;
2330import org .apache .jena .rdf .model .Model ;
2431import org .apache .jena .rdf .model .ModelFactory ;
2532import org .commonwl .view .git .GitDetails ;
2633import org .commonwl .view .workflow .Workflow ;
2734import org .commonwl .view .workflow .WorkflowOverview ;
28- import org .junit .Before ;
29- import org .junit .Rule ;
30- import org .junit .Test ;
31- import org .junit .rules .ExpectedException ;
32- import org .junit .runner .RunWith ;
35+ import org .junit .jupiter .api .Assertions ;
36+ import org .junit .jupiter .api .BeforeEach ;
37+ import org .junit .jupiter .api .Test ;
38+ import org .junit .jupiter .api .extension .ExtendWith ;
3339import org .mockito .Mockito ;
3440import org .mockito .invocation .InvocationOnMock ;
3541import org .mockito .stubbing .Answer ;
3642import org .springframework .boot .test .context .SpringBootTest ;
37- import org .springframework .test .context .junit4 . SpringRunner ;
43+ import org .springframework .test .context .junit . jupiter . SpringExtension ;
3844
3945import java .io .ByteArrayInputStream ;
4046import java .io .File ;
4450import java .util .Map ;
4551
4652import static org .apache .commons .io .FileUtils .readFileToString ;
47- import static org .junit .Assert .*;
53+ import static org .junit .jupiter .api .Assertions .assertEquals ;
54+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
55+ import static org .junit .jupiter .api .Assertions .assertNull ;
56+ import static org .junit .jupiter .api .Assertions .assertTrue ;
4857import static org .mockito .Matchers .anyObject ;
4958import static org .mockito .Matchers .anyString ;
5059import static org .mockito .Mockito .when ;
5160
52- @ RunWith ( SpringRunner .class )
61+ @ ExtendWith ( SpringExtension .class )
5362@ SpringBootTest
5463public class CWLServiceTest {
5564
@@ -58,7 +67,7 @@ public class CWLServiceTest {
5867 */
5968 private RDFService rdfService ;
6069
61- @ Before
70+ @ BeforeEach
6271 public void setUp () throws Exception {
6372 File packedWorkflowRdf = new File ("src/test/resources/cwl/make_to_cwl/dna.ttl" );
6473 Model workflowModel = ModelFactory .createDefaultModel ();
@@ -82,12 +91,6 @@ public ResultSet answer(InvocationOnMock invocation) throws Throwable {
8291 Mockito .doReturn (true ).when (rdfService ).graphExists (anyString ());
8392 }
8493
85- /**
86- * Used for expected IOExceptions for filesize limits
87- */
88- @ Rule
89- public ExpectedException thrown = ExpectedException .none ();
90-
9194 @ Test
9295 public void parsePackedWorkflowNativePath () throws Exception {
9396 CWLService cwlService = new CWLService (rdfService , Mockito .mock (CWLTool .class ), 5242880 );
@@ -180,13 +183,12 @@ public void parseWorkflowWithCwltool() throws Exception {
180183 public void workflowOverSingleFileSizeLimitThrowsIOException () throws Exception {
181184
182185 // Should throw IOException due to oversized files
183- thrown .expect (IOException .class );
184- thrown .expectMessage ("File 'lobSTR-workflow.cwl' is over singleFileSizeLimit - 2 KB/0 bytes" );
185-
186- CWLService cwlService = new CWLService (rdfService , Mockito .mock (CWLTool .class ), 0 );
187- cwlService .parseWorkflowNative (
188- Paths .get ("src/test/resources/cwl/lobstr-draft3/lobSTR-workflow.cwl" ), null );
189-
186+ Exception thrown = Assertions .assertThrows (IOException .class , () -> {
187+ CWLService cwlService = new CWLService (rdfService , Mockito .mock (CWLTool .class ), 0 );
188+ cwlService .parseWorkflowNative (
189+ Paths .get ("src/test/resources/cwl/lobstr-draft3/lobSTR-workflow.cwl" ), null );
190+ });
191+ assertEquals ("File 'lobSTR-workflow.cwl' is over singleFileSizeLimit - 2 KB/0 bytes" , thrown .getMessage ());
190192 }
191193
192194 /**
@@ -216,19 +218,17 @@ public void getHelloWorkflowOverview() throws Exception {
216218 */
217219 @ Test
218220 public void workflowOverviewOverSingleFileSizeLimitThrowsIOException () throws Exception {
219-
220- // Test cwl service
221- CWLService cwlService = new CWLService (Mockito .mock (RDFService .class ),
222- Mockito .mock (CWLTool .class ), 0 );
223-
224221 // File to test
225222 File helloWorkflow = new File ("src/test/resources/cwl/hello/hello.cwl" );
226223
227- // Should throw IOException due to oversized file
228- thrown .expect (IOException .class );
229- thrown .expectMessage (String .format ("File 'hello.cwl' is over singleFileSizeLimit - %s bytes/0 bytes" ,
230- helloWorkflow .length ()));
231- cwlService .getWorkflowOverview (helloWorkflow );
224+ // Test cwl service
225+ Exception thrown = Assertions .assertThrows (IOException .class , () -> {
226+ CWLService cwlService = new CWLService (Mockito .mock (RDFService .class ),
227+ Mockito .mock (CWLTool .class ), 0 );
228+ cwlService .getWorkflowOverview (helloWorkflow );
229+ });
230+ assertEquals (String .format ("File 'hello.cwl' is over singleFileSizeLimit - %s bytes/0 bytes" ,
231+ helloWorkflow .length ()), thrown .getMessage ());
232232
233233 }
234234
0 commit comments