Scufl2Tools { public void createActivityPortsFromProcessor(Activity activity, Processor processor) { for (InputProcessorPort processorPort : processor.getInputPorts()) new InputActivityPort(activity, processorPort.getName()) .setDepth(processorPort.getDepth()); for (OutputProcessorPort processorPort : processor.getOutputPorts()) { OutputActivityPort activityPort = new OutputActivityPort(activity, processorPort.getName()); activityPort.setDepth(processorPort.getDepth()); activityPort.setGranularDepth(processorPort.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 createActivityPortsFromProcessor() throws Exception { Processor p = new Processor(); new InputProcessorPort(p, "in1"); new InputProcessorPort(p, "in2").setDepth(1); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(0); OutputProcessorPort pOut3 = new OutputProcessorPort(p, "out3"); pOut3.setDepth(2); pOut3.setGranularDepth(1); Activity a = new Activity(); scufl2Tools.createActivityPortsFromProcessor(a, p); assertEquals(2, a.getInputPorts().size()); InputActivityPort aIn1 = a.getInputPorts().getByName("in1"); assertNull(aIn1.getDepth()); InputActivityPort aIn2 = a.getInputPorts().getByName("in2"); assertEquals(1, aIn2.getDepth().intValue()); assertEquals(3, a.getOutputPorts().size()); OutputActivityPort aOut1 = a.getOutputPorts().getByName("out1"); assertEquals(null, aOut1.getDepth()); assertEquals(null, aOut1.getGranularDepth()); OutputActivityPort aOut2 = a.getOutputPorts().getByName("out2"); assertEquals(0, aOut2.getDepth().intValue()); assertEquals(null, aOut2.getGranularDepth()); OutputActivityPort aOut3 = a.getOutputPorts().getByName("out3"); assertEquals(2, aOut3.getDepth().intValue()); assertEquals(1, aOut3.getGranularDepth().intValue()); }
@Test public void createActivityPortsFromProcessorWithOverwrite() throws Exception { Processor p = new Processor(); new InputProcessorPort(p, "in1"); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(1); Activity a = new Activity(); new InputActivityPort(a, "other"); OutputActivityPort toBeOverWritten = new OutputActivityPort(a, "out1"); toBeOverWritten.setDepth(1); assertEquals(a, toBeOverWritten.getParent()); scufl2Tools.createActivityPortsFromProcessor(a, p); assertNotNull(a.getInputPorts().getByName("other")); OutputActivityPort aOut1 = a.getOutputPorts().getByName("out1"); assertNull(aOut1.getDepth()); assertNotSame(toBeOverWritten, aOut1); }