@Override public void setParent(Workflow parent) { if (this.parent != null && this.parent != parent) { this.parent.getProcessors().remove(this); } this.parent = parent; if (parent != null) { parent.getProcessors().add(this); } }
private void checkCompleteness() { Workflow w = validatorState.get().getWorkflow(); if (w.getProcessors().isEmpty() && w.getOutputPorts().isEmpty()) { validatorState.get().getEventListener().incompleteWorkflow(w); // validatorState.get().addIncompleteWorkflow(w); } }
@Test public void controlLinksBlocking() { Processor hello = workflowBundle.getMainWorkflow().getProcessors() .getByName("Hello"); Processor wait4me = workflowBundle.getMainWorkflow().getProcessors() .getByName("wait4me"); ControlLink controlLink = workflowBundle.getMainWorkflow().getControlLinks() .iterator().next(); assertEquals(Collections.singletonList(controlLink), scufl2Tools.controlLinksBlocking(hello)); assertTrue(scufl2Tools.controlLinksBlocking(wait4me).isEmpty()); }
@Test public void controlLinksWaitingFor() { Processor hello = workflowBundle.getMainWorkflow().getProcessors() .getByName("Hello"); Processor wait4me = workflowBundle.getMainWorkflow().getProcessors() .getByName("wait4me"); ControlLink controlLink = workflowBundle.getMainWorkflow().getControlLinks() .iterator().next(); assertEquals(Collections.singletonList(controlLink), scufl2Tools.controlLinksWaitingFor(wait4me)); assertTrue(scufl2Tools.controlLinksWaitingFor(hello).isEmpty()); }
@Test public void uriForProcessor() throws Exception { URI uri = uriTools.uriForBean(wfBundle.getMainWorkflow() .getProcessors().getByName("Hello")); assertEquals(HELLO_URI, uri.toASCIIString()); }
@Test public void uriForDatalinkWithMerge() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); List<DataLink> greetingLinks = scufl2Tools.datalinksFrom(hello .getOutputPorts().getByName("greeting")); URI uri = uriTools.uriForBean(greetingLinks.get(0)); assertEquals( HELLOWORLD_URI + "datalink?from=processor/Hello/out/greeting&to=out/results&mergePosition=0", uri.toASCIIString()); }
@Test public void uriForIterationStrategyStack() throws Exception { URI uri = uriTools .uriForBean(wfBundle.getMainWorkflow().getProcessors() .getByName("Hello").getIterationStrategyStack()); assertEquals(HELLO_URI + "iterationstrategy/", uri.toASCIIString()); }
@Test public void uriForDatalink() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); List<DataLink> nameLinks = scufl2Tools.datalinksTo(hello .getInputPorts().getByName("name")); URI uri = uriTools.uriForBean(nameLinks.get(0)); assertEquals(HELLOWORLD_URI + "datalink?from=in/yourName&to=processor/Hello/in/name", uri.toASCIIString()); }
@Test public void resolveProcessorOutput() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); OutputProcessorPort greeting = hello.getOutputPorts().getByName( "greeting"); assertSame(greeting, uriTools.resolveUri( HELLO_URI.resolve("out/greeting"), wfBundle)); }
@Test public void uriForProcessorInPort() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); URI uri = uriTools.uriForBean(hello.getInputPorts().getByName("name")); assertEquals(HELLO_URI + "in/name", uri.toASCIIString()); }
@Test public void resolveProcessorInput() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); InputProcessorPort helloName = hello.getInputPorts().getByName("name"); assertSame(helloName, uriTools.resolveUri(HELLO_URI.resolve("in/name"), wfBundle)); }
@Test public void resolveProcessorIterationStrategy() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertSame(hello.getIterationStrategyStack().get(0), uriTools.resolveUri( HELLO_URI.resolve("iterationstrategy/0/"), wfBundle)); }
@Test public void uriForProcessorOutPort() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); URI uri = uriTools.uriForBean(hello.getOutputPorts().getByName( "greeting")); assertEquals(HELLO_URI + "out/greeting", uri.toASCIIString()); }
@Test public void resolveProcessor() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertSame(hello, uriTools.resolveUri(HELLO_URI, wfBundle)); }
@Test public void resolveProcessorIterationStrategyRoot() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertSame(hello.getIterationStrategyStack().get(0), uriTools.resolveUri(HELLO_URI.resolve("iterationstrategy/0/"), wfBundle)); }
@Test public void uriForIterationStrategyRoot() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); URI uri = uriTools.uriForBean(hello.getIterationStrategyStack().get(0)); assertEquals(HELLO_URI + "iterationstrategy/0/", uri.toASCIIString()); }
@Test public void uriForIterationStrategyCross() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); CrossProduct crossProduct = (CrossProduct) hello .getIterationStrategyStack().get(0); URI uri = uriTools.uriForBean(crossProduct.get(0)); assertEquals(HELLO_URI + "iterationstrategy/0/0/", uri.toASCIIString()); }
@Test public void resolveProcessorIterationStrategyNode() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); CrossProduct rootStrategyNode = (CrossProduct) hello .getIterationStrategyStack().get(0); assertSame(rootStrategyNode.get(0), uriTools.resolveUri( HELLO_URI.resolve("iterationstrategy/0/0/"), wfBundle)); }
@Test public void readBundleStream() throws Exception { InputStream inputStream = new ByteArrayInputStream( getStructureFormatWorkflowBundle().getBytes("utf-8")); WorkflowBundle wfBundle = bundleIO.readBundle(inputStream, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertEquals("HelloWorld", wfBundle.getName()); assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName()); assertTrue(wfBundle.getMainWorkflow().getProcessors() .containsName("Hello")); }
@Test public void cloneWorkflow() throws Exception { Workflow original = originalWfBundle.getMainWorkflow(); assertEquals(originalWfBundle, original.getParent()); Workflow clone = (Workflow) original.clone(); assertNull(clone.getParent()); assertEquals(original.getName(), clone.getName()); assertNotSame(original.getProcessors().getByName("Hello"), clone .getProcessors().getByName("Hello")); assertNotSame(original.getCurrentRevision(), clone.getCurrentRevision()); assertEquals(original.getCurrentRevision(), clone.getCurrentRevision()); }