taverna-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stain <...@git.apache.org>
Subject [GitHub] incubator-taverna-language pull request #38: Cwlparser
Date Wed, 20 Jun 2018 12:25:48 GMT
Github user stain commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/38#discussion_r196754088
  
    --- Diff: taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
---
    @@ -0,0 +1,96 @@
    +package org.apache.taverna.scufl2.cwl;
    +
    +
    +import java.util.Set;
    +import java.util.HashSet;
    +
    +import org.junit.Before;
    +import org.junit.Test;
    +import static org.junit.Assert.assertEquals;
    +
    +import org.yaml.snakeyaml.Yaml;
    +
    +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;
    +
    +import org.apache.taverna.scufl2.api.core.Workflow;
    +import org.apache.taverna.scufl2.api.core.Processor;
    +import org.apache.taverna.scufl2.api.core.DataLink;
    +
    +import org.apache.taverna.scufl2.api.common.NamedSet;
    +
    +import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
    +import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
    +import org.apache.taverna.scufl2.api.port.InputProcessorPort;
    +
    +
    +public class TestParser {
    +    private static final String HELLO_WORLD_CWL = "/hello_world.cwl";
    +
    +    private static JsonNode cwlFile;
    +    private WorkflowParser parser;
    +    private Workflow workflow;
    +
    +    @Before
    +    public void initialize() {
    +
    +        Yaml reader = new Yaml();
    +        ObjectMapper mapper = new ObjectMapper();
    +        cwlFile = mapper.valueToTree(reader.load(TestParser.class.getResourceAsStream(HELLO_WORLD_CWL)));
    +        System.out.println(cwlFile);
    +        this.parser = new WorkflowParser(cwlFile);
    +
    +        this.workflow = parser.buildWorkflow();
    +    }
    +
    +    @Test
    +    public void testParseInputs() throws Exception {
    +
    +        NamedSet<InputWorkflowPort> workflowInputs = workflow.getInputPorts();
    +        NamedSet<InputWorkflowPort> expectedInputs = new NamedSet<>();
    +        expectedInputs.add(new InputWorkflowPort(workflow, "name"));
    +
    +        assertEquals(expectedInputs, workflowInputs);
    +    }
    +
    +    @Test
    +    public void testParseOutputs() throws Exception {
    +
    +        NamedSet<OutputWorkflowPort> workflowOutputs = workflow.getOutputPorts();
    +        NamedSet<OutputWorkflowPort> expectedOutputs = new NamedSet<>();
    +
    +        assertEquals(expectedOutputs, workflowOutputs);
    +    }
    +
    +    @Test
    +    public void testParseProcessors() throws Exception {
    +
    +        NamedSet<Processor> workflowProcessors = workflow.getProcessors();
    +        NamedSet<Processor> expectedProcessors = new NamedSet<>();
    +        expectedProcessors.add(new Processor(workflow, "step1"));
    +
    +        assertEquals(expectedProcessors, workflowProcessors);
    +    }
    +
    +    @Test
    +    public void testParseDataLinks() throws Exception {
    +
    +        Set<DataLink> workflowDataLinks = workflow.getDataLinks();
    +        Set<DataLink> expectedDataLinks = new HashSet<>();
    +        Set<Processor> processorSet = workflow.getProcessors();
    +        // processorSet has one processor
    +        Processor processor = processorSet.iterator().next();
    --- End diff --
    
    perhaps you can get it from [processorSet.getByName()](https://github.com/apache/incubator-taverna-language/blob/master/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/common/NamedSet.java#L196)
if you type `processorSet` as `NamedSet` instead.



---

Mime
View raw message