/** * Constructs a <code>DataLink</code> with the specified parent * {@link Workflow} that connects the specified {@link SenderPort} and * {@link ReceiverPort}. * * @param parent * the <code>Workflow</code> to set as the <code>DataLink</code> * 's parent. Can be <code>null</code>. * @param senderPort * the <code>SenderPort</code> that the <code>DataLink</code> * receives data from. Can be <code>null</code>. * @param receiverPort * the <code>ReceiverPort</code> that the <code>DataLink</code> * sends data to. Can be <code>null</code>. */ public DataLink(Workflow parent, SenderPort senderPort, ReceiverPort receiverPort) { setReceivesFrom(senderPort); setSendsTo(receiverPort); setParent(parent); }
@Test public void dataLinkNotAddedTwice() throws Exception { assertEquals(3, workflow.getDataLinks().size()); DataLink dl1 = workflow.getDataLinks().iterator().next(); assertTrue(workflow.getDataLinks().contains(dl1)); workflow.getDataLinks().add(dl1); dl1.setParent(workflow); // This could happen because dataLink.compareTo() calls // .compareTo() on the sender/receiver link, and if // their parents was null at insertion and non-null // later, the TreeSet order got messed up. assertEquals(3, workflow.getDataLinks().size()); }
protected void parseDataLink(DataLink original) { URI fromUri = getParserState().getCurrentBase().resolve( original.getReceiveFrom().getResource()); URI toUri = getParserState().getCurrentBase().resolve( original.getSendTo().getResource()); WorkflowBean from = resolveBeanUri(fromUri); WorkflowBean to = resolveBeanUri(toUri); org.apache.taverna.scufl2.api.core.DataLink link = new org.apache.taverna.scufl2.api.core.DataLink(); link.setReceivesFrom((SenderPort) from); link.setSendsTo((ReceiverPort) to); if (original.getMergePosition() != null) link.setMergePosition(original.getMergePosition().getValue()); link.setParent(getParserState().getCurrent(Workflow.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), link); }
Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w);
@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); }
@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); }
@Test public void testInScopeProcessorPorts() { Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w); Processor p1 = new Processor(); p1.setParent(w); InputProcessorPort ipp = new InputProcessorPort(); ipp.setParent(p1); Processor p2 = new Processor(); p2.setParent(w); OutputProcessorPort opp = new OutputProcessorPort(); opp.setParent(p2); dataLink.setReceivesFrom(opp); dataLink.setSendsTo(ipp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, true, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }