@Test public void orderedByClassName() throws Exception { ports.add(new InputWorkflowPort(wf, "p3")); ports.add(new OutputWorkflowPort(wf, "p1")); ports.add(new InputWorkflowPort(wf, "p2")); Collections.sort(ports); assertNamesEqual(ports, "p2", "p3", "p1"); }
protected void parseOutputWorkflowPort( uk.org.taverna.scufl2.rdfxml.jaxb.OutputWorkflowPort original) { uk.org.taverna.scufl2.api.port.OutputWorkflowPort port = new uk.org.taverna.scufl2.api.port.OutputWorkflowPort(); port.setName(original.getName()); port.setParent(getParserState().getCurrent(Workflow.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), port); }
@Test public void testCorrectnessOfMergePositionSpecifiedCorrectly() { Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w); InputWorkflowPort iwp = new InputWorkflowPort(); iwp.setParent(w); OutputWorkflowPort owp = new OutputWorkflowPort(); owp.setParent(w); dataLink.setReceivesFrom(iwp); dataLink.setSendsTo(owp); Integer mergePosition = Integer.valueOf(3); dataLink.setMergePosition(mergePosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); }
/** * Constructs an <code>OutputWorkflowPort</code> for the specified <code>Workflow</code> with * the specified name. * <p> * The <code>OutputPort</code> is added to the <code>Workflow</code> (if the * <code>Workflow</code> is not <code>null</code>). * * @param parent * the <code>Workflow</code> to add this <code>Port</code> to. Can be * <code>null</code> * @param name * the name of the <code>Port</code>. <strong>Must not</strong> be <code>null</code> * or an empty String. */ public OutputWorkflowPort(Workflow parent, String name) { super(name); setParent(parent); }
iwp.setParent(otherWorkflow); OutputWorkflowPort owp = new OutputWorkflowPort(); owp.setParent(w);
/** * Set the <code>OutputWorkflowPort</code>s to be the contents of the * specified set. * <p> * <code>OutputWorkflowPort</code>s can be added by using * {@link #getOutputWorkflowPorts()}.add(outputPort). * * @param outputPorts * the <code>OutputWorkflowPort</code>s. <strong>Must * not</strong> be null */ public void setOutputPorts(Set<OutputWorkflowPort> outputPorts) { this.outputPorts.clear(); for (OutputWorkflowPort outputPort : outputPorts) { outputPort.setParent(this); } }
iwp.setParent(w); OutputWorkflowPort owp = new OutputWorkflowPort(); owp.setParent(otherWorkflow);
@SuppressWarnings("unchecked") @Test public void expectedOrder() throws Exception { Workflow wf = new Workflow(); wf.setName("wf"); InputWorkflowPort a = new InputWorkflowPort(wf, "a"); InputWorkflowPort b = new InputWorkflowPort(wf, "b"); InputWorkflowPort c = new InputWorkflowPort(wf, "c"); OutputWorkflowPort x = new OutputWorkflowPort(wf, "x"); OutputWorkflowPort y = new OutputWorkflowPort(wf, "y"); OutputWorkflowPort z = new OutputWorkflowPort(wf, "z"); DataLink c_x = new DataLink(wf, c, x); DataLink b_x = new DataLink(wf, b, x); DataLink b_z = new DataLink(wf, b, z); DataLink a_z = new DataLink(wf, a, z); DataLink a_x = new DataLink(wf, a, x); ArrayList<DataLink> links = new ArrayList<DataLink>(wf.getDataLinks()); assertEquals(Arrays.asList(a_x, a_z, b_x, b_z, c_x), links); Collections.shuffle(links); Collections.sort(links); assertEquals(Arrays.asList(a_x, a_z, b_x, b_z, c_x), links); }
iwp.setParent(w); OutputWorkflowPort owp = new OutputWorkflowPort(); owp.setParent(w);
new InputWorkflowPort(workflow, portName); } else { new OutputWorkflowPort(workflow, portName);
@Test public void testInScopePorts() { Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w); InputWorkflowPort iwp = new InputWorkflowPort(); iwp.setParent(w); OutputWorkflowPort owp = new OutputWorkflowPort(); owp.setParent(w); dataLink.setReceivesFrom(iwp); dataLink.setSendsTo(owp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, true, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }
InputWorkflowPort c = new InputWorkflowPort(wf, "c"); OutputWorkflowPort x = new OutputWorkflowPort(wf, "x"); OutputWorkflowPort y = new OutputWorkflowPort(wf, "y"); OutputWorkflowPort z = new OutputWorkflowPort(wf, "z");
@Test public void testCorrectnessOfMissingReceivesFrom() { DataLink dataLink = new DataLink(); OutputWorkflowPort owp = new OutputWorkflowPort(); dataLink.setSendsTo(owp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, false, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(0, nullFieldProblems.size()); // only done when completeness check }
@Test public void testCompletenessOfMissingReceivesFrom() { DataLink dataLink = new DataLink(); OutputWorkflowPort owp = new OutputWorkflowPort(); dataLink.setSendsTo(owp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertFalse(nullFieldProblems.isEmpty()); // only done when completeness check boolean fieldProblem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(dataLink) && nlp.getFieldName().equals("receivesFrom")) { fieldProblem = true; } } assertTrue(fieldProblem); }
@Test public void testDataLinkInheritanceFromInputWorkflowPorts() { WorkflowBundle wb = new WorkflowBundle(); Workflow w = new Workflow(); wb.setMainWorkflow(w); InputWorkflowPort a = new InputWorkflowPort(w, "a"); a.setDepth(0); InputWorkflowPort b = new InputWorkflowPort(w, "b"); b.setDepth(7); OutputWorkflowPort outA = new OutputWorkflowPort(w, "outA"); OutputWorkflowPort outB = new OutputWorkflowPort(w, "outB"); DataLink aLink = new DataLink(w, a, outA); DataLink bLink = new DataLink(w, b, outB); StructuralValidator sv = new StructuralValidator(); ReportStructuralValidationListener l = new ReportStructuralValidationListener(); sv.checkStructure(wb, l); ValidatorState vs = sv.getValidatorState(); assertEquals(0, l.getIncompleteWorkflows().size()); assertEquals(Integer.valueOf(0), vs.getDataLinkResolvedDepth(aLink)); assertEquals(Integer.valueOf(7), vs.getDataLinkResolvedDepth(bLink)); assertEquals(Integer.valueOf(0), vs.getPortResolvedDepth(outA)); assertEquals(Integer.valueOf(7), vs.getPortResolvedDepth(outB)); }
b.setDepth(7); OutputWorkflowPort outA = new OutputWorkflowPort(w, "outA"); OutputWorkflowPort outB = new OutputWorkflowPort(w, "outB");
public Workflow makeMainWorkflow() { workflow = new Workflow(); workflow.setName("HelloWorld"); // NOTE: setWorkflowIdentifier should only be called when loading a // workflow // which already has an ID workflow.setIdentifier(URI .create("http://ns.taverna.org.uk/2010/workflow/00626652-55ae-4a9e-80d4-c8e9ac84e2ca/")); InputWorkflowPort yourName = new InputWorkflowPort(workflow, "yourName"); yourName.setDepth(0); OutputWorkflowPort results = new OutputWorkflowPort(workflow, "results"); // Not needed: // workflow.getInputPorts().add(yourName); // workflow.getOutputPorts().add(results); workflow.getProcessors().add(makeProcessor()); workflow.getProcessors().add(makeProcessor2()); // Make links DataLink directLink = new DataLink(workflow, yourName, results); directLink.setMergePosition(1); DataLink greetingLink = new DataLink(workflow, processorGreeting, results); greetingLink.setMergePosition(0); nameLink = new DataLink(workflow, yourName, processorName); condition = new BlockingControlLink(processor, wait4me); return workflow; }
.getInputPorts()); OutputWorkflowPort wf1_out1 = new OutputWorkflowPort(wf1, "out1"); assertTrue("Did not add 'out1' to list of output ports", wf1 .getOutputPorts().contains(wf1_out1)); new OutputWorkflowPort(wf1, "out1");