Scufl2Tools { public void createProcessorPortsFromActivity(Processor processor, Activity activity) { for (InputActivityPort activityPort : activity.getInputPorts()) new InputProcessorPort(processor, activityPort.getName()) .setDepth(activityPort.getDepth()); for (OutputActivityPort activityPort : activity.getOutputPorts()) { OutputProcessorPort procPort = new OutputProcessorPort(processor, activityPort.getName()); procPort.setDepth(activityPort.getDepth()); procPort.setGranularDepth(activityPort.getGranularDepth()); } }  List<Annotation> annotationsFor(Child<?> bean); List<Annotation> annotationsFor(WorkflowBean bean,
			WorkflowBundle bundle); Configuration configurationFor(Configurable configurable,
			Profile profile); Configuration configurationForActivityBoundToProcessor(
			Processor processor, Profile profile); List<Configuration> configurationsFor(Configurable configurable,
			Profile profile); @SuppressWarnings("unchecked") List<BlockingControlLink> controlLinksBlocking(Processor blocked); @SuppressWarnings("unchecked") List<BlockingControlLink> controlLinksWaitingFor(
			Processor untilFinished); @SuppressWarnings("unchecked") List<DataLink> datalinksFrom(SenderPort senderPort); @SuppressWarnings("unchecked") List<DataLink> datalinksTo(ReceiverPort receiverPort); T findParent(Class<T> parentClass,
			Child<?> child); JsonNode portDefinitionFor(ActivityPort activityPort, Profile profile); ProcessorBinding processorBindingForProcessor(Processor processor,
			Profile profile); List<ProcessorBinding> processorBindingsForProcessor(
			Processor processor, Profile profile); List<ProcessorBinding> processorBindingsToActivity(Activity activity); ProcessorInputPortBinding processorPortBindingForPort(
			InputPort inputPort, Profile profile); ProcessorOutputPortBinding processorPortBindingForPort(
			OutputPort outputPort, Profile profile); void setParents(WorkflowBundle bundle); Set<Processor> possibleDownStreamProcessors(Workflow dataflow,
			Processor processor); Set<Processor> possibleUpStreamProcessors(Workflow dataflow,
			Processor firstProcessor); ProcessorSplit splitProcessors(Collection<Processor> processors,
			Processor splitPoint); Workflow nestedWorkflowForProcessor(Processor processor,
			Profile profile); List<Workflow> nestedWorkflowsForProcessor(Processor processor,
			Profile profile); boolean containsNestedWorkflow(Processor processor); boolean containsNestedWorkflow(Processor processor, Profile profile); void createActivityPortsFromProcessor(Activity activity,
			Processor processor); void createProcessorPortsFromActivity(Processor processor,
			Activity activity); ProcessorBinding bindActivityToProcessorByMatchingPorts(
			Activity activity, Processor processor); void bindActivityToProcessorByMatchingPorts(ProcessorBinding binding); ProcessorBinding createProcessorAndBindingFromActivity(
			Activity activity); Activity createActivityFromProcessor(Processor processor,
			Profile profile); Configuration setAsNestedWorkflow(Processor processor, Workflow childWorkflow, Profile profile); void removePortsBindingForUnknownPorts(ProcessorBinding binding); void updateBindingByMatchingPorts(ProcessorBinding binding); Processor createConstant(Workflow workflow, Profile profile,
			String name); Configuration createConfigurationFor(Activity activity,
			URI configType); Configuration createConfigurationFor(Processor processor,
			Profile profile); void setConstantStringValue(Processor constant, String value,
			Profile profile); String getConstantStringValue(Processor constant, Profile profile); Set<Processor> getConstants(Workflow workflow, Profile profile); void createDefaultIterationStrategyStack(Processor p); static URI PORT_DEFINITION; static URI NESTED_WORKFLOW; static URI CONSTANT; static URI CONSTANT_CONFIG; }
@Test public void createProcessorPortsFromActivity() throws Exception { Activity a = new Activity(); new InputActivityPort(a, "in1"); new InputActivityPort(a, "in2").setDepth(1); new OutputActivityPort(a, "out1"); new OutputActivityPort(a, "out2").setDepth(0); OutputActivityPort aOut3 = new OutputActivityPort(a, "out3"); aOut3.setDepth(2); aOut3.setGranularDepth(1); Processor p = new Processor(); scufl2Tools.createProcessorPortsFromActivity(p, a); assertEquals(2, p.getInputPorts().size()); InputProcessorPort pIn1 = p.getInputPorts().getByName("in1"); assertNull(pIn1.getDepth()); InputProcessorPort pIn2 = p.getInputPorts().getByName("in2"); assertEquals(1, pIn2.getDepth().intValue()); assertEquals(3, p.getOutputPorts().size()); OutputProcessorPort pOut1 = p.getOutputPorts().getByName("out1"); assertEquals(null, pOut1.getDepth()); assertEquals(null, pOut1.getGranularDepth()); OutputProcessorPort pOut2 = p.getOutputPorts().getByName("out2"); assertEquals(0, pOut2.getDepth().intValue()); assertEquals(null, pOut2.getGranularDepth()); OutputProcessorPort pOut3 = p.getOutputPorts().getByName("out3"); assertEquals(2, pOut3.getDepth().intValue()); assertEquals(1, pOut3.getGranularDepth().intValue()); }
@Test public void createProcessorPortsFromActivityWithOverwrite() throws Exception { Activity a = new Activity(); new InputActivityPort(a, "in1"); new OutputActivityPort(a, "out1"); new OutputActivityPort(a, "out2").setDepth(1); Processor p = new Processor(); new InputProcessorPort(p, "other"); OutputProcessorPort toBeOverWritten = new OutputProcessorPort(p, "out1"); toBeOverWritten.setDepth(1); assertEquals(p, toBeOverWritten.getParent()); scufl2Tools.createProcessorPortsFromActivity(p, a); assertNotNull(p.getInputPorts().getByName("other")); OutputProcessorPort pOut1 = p.getOutputPorts().getByName("out1"); assertNull(pOut1.getDepth()); assertNotSame(toBeOverWritten, pOut1); }