@Test public void crossProductNotEqual() throws Exception { CrossProduct crossProd1 = new CrossProduct(); CrossProduct crossProd2 = new CrossProduct(); crossProd2.add(new PortNode()); assertNotEquals(crossProd1, crossProd2); }
public IterationStrategyStack makeIterationStrategyStack( InputProcessorPort... inputs) { IterationStrategyStack stack = new IterationStrategyStack(); CrossProduct crossProduct = new CrossProduct(); crossProduct.setParent(stack); for (InputProcessorPort inp : inputs) { PortNode n = new PortNode(crossProduct, inp); n.setDesiredDepth(0); } return stack; }
private Integer getCrossProductIterationDepth(CrossProduct crossProduct, Map<InputProcessorPort, Integer> inputDepths) { if (crossProduct.isEmpty()) { validatorState.get().getEventListener() .emptyCrossProduct(crossProduct); // validatorState.get().addEmptyCrossProduct(crossProduct); validatorState.get().getEventListener() .failedProcessorAdded(validatorState.get().getProcessor()); // validatorState.get().failCurrentProcessor(); return null; } int temp = 0; for (IterationStrategyNode child : crossProduct) { Integer childNodeDepth = getIterationDepth(child, inputDepths); if (childNodeDepth == null) return null; temp += childNodeDepth; } return temp; }
CrossProduct cp = new CrossProduct(); iss.add(cp); cp.setParent(iss); PortNode pn = new PortNode(); pn.setInputProcessorPort(ipp); cp.add(pn); pn.setParent(cp);
@Test public void crossProductEqualIfEmpty() throws Exception { CrossProduct crossProd1 = new CrossProduct(); CrossProduct crossProd2 = new CrossProduct(); assertEquals(crossProd1, crossProd2); }
@Test public void iterationStrategy() throws Exception { Processor hello = workflowBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertEquals(1, hello.getIterationStrategyStack().size()); IterationStrategyTopNode iterationStrategyTopNode = hello .getIterationStrategyStack().get(0); assertTrue(iterationStrategyTopNode instanceof CrossProduct); CrossProduct cross = (CrossProduct) iterationStrategyTopNode; assertEquals(1, cross.size()); PortNode portNode = (PortNode) cross.get(0); assertEquals(hello.getInputPorts().getByName("name"), portNode.getInputProcessorPort()); assertEquals(0, portNode.getDesiredDepth().intValue()); }
@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 testInScopeInputProcessorPort() { Processor p = new Processor(); InputProcessorPort ipp = new InputProcessorPort(); ipp.setParent(p); IterationStrategyStack iss = new IterationStrategyStack(); p.setIterationStrategyStack(iss); CrossProduct cp = new CrossProduct(); iss.add(cp); cp.setParent(iss); PortNode pn = new PortNode(); pn.setInputProcessorPort(ipp); cp.add(pn); pn.setParent(cp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pn, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }
@Test public void iterationStackNotEqualToCrossProduct() throws Exception { IterationStrategyStack itStack = new IterationStrategyStack(); CrossProduct crossProd = new CrossProduct(); assertNotEquals(itStack, crossProd); }
@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()); }
CrossProduct cp = new CrossProduct(); PortNode pNode1 = new PortNode(); pNode1.setInputProcessorPort(p1); cp.add(pNode1); PortNode duplicateNode = new PortNode(); duplicateNode.setInputProcessorPort(p1); cp.add(duplicateNode); iss.add(cp); dp.add(pNode2); dp.add(pNode3); cp.add(dp);
protected IterationStrategyNode parseIterationStrategyNode( IterationNode topNode) throws ReaderException { if (topNode instanceof PortProduct) { PortProduct portProduct = (PortProduct) topNode; PortNode portNode = new PortNode(); portNode.setDesiredDepth(portProduct.getDepth().intValue()); String name = portProduct.getName(); Processor processor = parserState.get().getCurrentProcessor(); InputProcessorPort inputProcessorPort = processor.getInputPorts() .getByName(name); portNode.setInputProcessorPort(inputProcessorPort); return portNode; } IterationStrategyNode node; if (topNode instanceof DotProduct) node = new org.apache.taverna.scufl2.api.iterationstrategy.DotProduct(); else if (topNode instanceof CrossProduct) node = new org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct(); else throw new ReaderException("Invalid node " + topNode); @SuppressWarnings("unchecked") List<IterationStrategyNode> children = (List<IterationStrategyNode>) node; IterationNodeParent parent = (IterationNodeParent) topNode; for (IterationNode child : parent.getCrossOrDotOrPort()) children.add(parseIterationStrategyNode(child)); return node; }
protected void parseCrossProduct(CrossProduct original) throws ReaderException { org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct cross = new org.apache.taverna.scufl2.api.iterationstrategy.CrossProduct(); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), cross); cross.setParent(getParserState().getCurrent( IterationStrategyParent.class)); getParserState().push(cross); try { parseProductOf(original.getProductOf()); } finally { getParserState().pop(); } }
CrossProduct cp = new CrossProduct(); PortNode pNode1 = new PortNode(); pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp); PortNode duplicateNode = new PortNode(); duplicateNode.setInputProcessorPort(p1); cp.add(duplicateNode); cp.add(dp);
@Test public void crossProductNotEqualToDotProduct() throws Exception { DotProduct dotProd = new DotProduct(); CrossProduct crossProd = new CrossProduct(); assertNotEquals(crossProd, dotProd); assertNotEquals(dotProd, crossProd); }
p3.setParent(p); CrossProduct cp = new CrossProduct(); PortNode pNode1 = new PortNode(); pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp);
private CrossProduct getCross(int depthA, int depthB) { a = new InputProcessorPort(); a.setName("a"); a.setDepth(0); CrossProduct cp = new CrossProduct(); PortNode nipn1 = new PortNode(cp, a); nipn1.setDesiredDepth(depthA); b = new InputProcessorPort(); b.setName("b"); b.setDepth(0); PortNode nipn2 = new PortNode(cp, b); nipn2.setDesiredDepth(depthB); return cp; }
CrossProduct cp = new CrossProduct(); PortNode pNode1 = new PortNode(); pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp); dp.add(pNode2); dp.add(pNode3); cp.add(dp);
private CrossProduct getCross(int depthA, int depthB) { a = new InputProcessorPort(); a.setName("a"); a.setDepth(0); CrossProduct cp = new CrossProduct(); PortNode nipn1 = new PortNode(cp, a); nipn1.setDesiredDepth(depthA); b = new InputProcessorPort(); b.setName("b"); b.setDepth(0); PortNode nipn2 = new PortNode(cp, b); nipn2.setDesiredDepth(depthB); return cp; }
p3.setParent(p); CrossProduct cp = new CrossProduct(); PortNode pNode1 = new PortNode(); pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp);