You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2018/07/16 09:22:21 UTC

[07/15] incubator-taverna-language git commit: Add dummy test and workflow example

Add dummy test and workflow example


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/ee6b282e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ee6b282e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ee6b282e

Branch: refs/heads/master
Commit: ee6b282edad17a1095af7a3c6a885c383ca71ee5
Parents: ba29413
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 4 10:38:37 2018 +0100
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 4 10:38:37 2018 +0100

----------------------------------------------------------------------
 .../apache/taverna/scufl2/cwl/TestParser.java   | 97 +++++++-------------
 .../src/test/resources/simple_string_input.cwl  |  5 +-
 2 files changed, 37 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ee6b282e/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
index 01b5bc2..83c48e1 100644
--- a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -1,84 +1,53 @@
 package org.apache.taverna.scufl2.cwl;
 
-import java.io.*;
-import java.util.ArrayList;
+
+import java.util.*;
 
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
-import org.apache.commons.io.FileUtils;
-
-import org.apache.taverna.scufl2.cwl.Parser;
-import org.apache.taverna.scufl2.cwl.InputField;
-
-public class TestParser {
-
-    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
-    private static final String INT_INPUT = "/int_input.cwl";
-
-    @Test
-    public void testGetDepth() throws Exception {
-
-        assert Parser.getDepth("  test") == 1;
-        assert Parser.getDepth("test") == 0;
-        assert Parser.getDepth("    test") == 2;
-    }
-
-    @Test
-    public void testGetKey() throws Exception {
 
-        assert Parser.getKeyFromLine("  test: test_value").equals("test");
-        assert Parser.getKeyFromLine("test: 1 ").equals("test");
-        assert Parser.getKeyFromLine("    test:").equals("test");
-    }
+import org.yaml.snakeyaml.Yaml;
 
-    @Test
-    public void testGetValue() throws Exception {
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 
-        assert Parser.getValueFromLine("  test: test_value").equals("test_value");
-        assert Parser.getValueFromLine("test: 1 ").equals("1");
-        assert Parser.getValueFromLine("    test:").equals("");
-    }
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
 
-    @Test
-    public void testSimpleInput() throws Exception {
-        File yaml = FileUtils.getFile("src", "test", "resources", SIMPLE_STRING_INPUT);
 
-        Parser parser = new Parser(yaml);
-
-        ArrayList<InputField> inputs = parser.parseInputs();
+public class TestParser {
+    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
+    private static final String INT_INPUT = "/int_input.cwl";
 
-        assertEquals(1, inputs.size());
-        assertEquals("example_string", inputs.get(0).key);
-    }
+    private static JsonNode cwlFile;
 
     @Test
-    public void testIntInput() throws Exception {
-        File yaml = FileUtils.getFile("src", "test", "resources", INT_INPUT);
-
-        Parser parser = new Parser(yaml);
+    public void testStringInput() throws Exception {
 
-        ArrayList<InputField> inputs = parser.parseInputs();
+        Yaml reader = new Yaml();
+        ObjectMapper mapper = new ObjectMapper();
+        cwlFile = mapper.valueToTree(reader.load(TestParser.class.getResourceAsStream(SIMPLE_STRING_INPUT)));
+        System.out.println(cwlFile);
+        Parser parser = new Parser(cwlFile);
 
-        assertEquals(1, inputs.size());
-        assertEquals("example_int", inputs.get(0).key);
-        assertEquals("int", inputs.get(0).type);
-        assertEquals(2, inputs.get(0).position);
-        assertEquals("-i", inputs.get(0).prefix);
-    }
+        Set<InputWorkflowPort> result = parser.parseInputs();
+        for(InputWorkflowPort port: result) {
+            System.out.println(port.getName());
+        }
+        ArrayList<InputWorkflowPort> inputs = new ArrayList<>(result);
+        assertEquals(inputs.get(0).getName(), "example_string");
 
-    void printFile(File yaml) throws Exception {
-        /**
-         * Print file
-         */
-        FileReader fdesc = new FileReader(yaml);
-        BufferedReader bufferedReader = new BufferedReader(fdesc);
-        String yamlLine;
-        while((yamlLine = bufferedReader.readLine()) != null) {
-            System.out.println(yamlLine);
+        Set<OutputWorkflowPort> result2 = parser.parseOutputs();
+        for(OutputWorkflowPort port: result2) {
+            System.out.println(port.getName());
         }
+        System.out.println("Showing steps:");
 
-        System.out.println("*************************");
-        bufferedReader.close();
-        /*****/
+        Set<Step> steps = parser.parseSteps();
+        for(Step step: steps) {
+            System.out.println(step);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ee6b282e/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
index c075b22..b474f9d 100644
--- a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
@@ -1,2 +1,5 @@
 inputs:
-  example_string: string
\ No newline at end of file
+  example_string: string
+steps:
+  step1:
+    run: run1
\ No newline at end of file