@Test public void dotProductNotEqual() throws Exception { DotProduct dotProd1 = new DotProduct(); DotProduct dotProd2 = new DotProduct(); dotProd2.add(new PortNode()); assertNotEquals(dotProd1, dotProd2); }
public Integer getDotProductIterationDepth(DotProduct dotProduct, Map<InputProcessorPort, Integer> inputDepths) { if (dotProduct.isEmpty()) { validatorState.get().getEventListener().emptyDotProduct(dotProduct); Integer depth = getIterationDepth(dotProduct.get(0), inputDepths); if (depth == null) return null;
protected void parseDotProduct(DotProduct original) throws ReaderException { org.apache.taverna.scufl2.api.iterationstrategy.DotProduct dot = new org.apache.taverna.scufl2.api.iterationstrategy.DotProduct(); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), dot); dot.setParent(getParserState() .getCurrent(IterationStrategyParent.class)); getParserState().push(dot); try { parseProductOf(original.getProductOf()); } finally { getParserState().pop(); } }
@Test public void dotProductEqualIfEmpty() throws Exception { DotProduct dotProd1 = new DotProduct(); DotProduct dotProd2 = new DotProduct(); assertEquals(dotProd1, dotProd2); }
@Test public void crossAndDot() throws Exception { assertEquals(1, shape.getIterationStrategyStack().size()); IterationStrategyTopNode top = shape.getIterationStrategyStack().get(0); assertTrue(top instanceof CrossProduct); assertEquals(2, top.size()); IterationStrategyNode node1 = top.get(0); assertTrue(node1 instanceof PortNode); PortNode portNode1 = (PortNode) node1; assertEquals(0, portNode1.getDesiredDepth().intValue()); assertEquals(shape.getInputPorts().getByName("string1"), portNode1.getInputProcessorPort()); IterationStrategyNode node2 = top.get(1); assertTrue(node2 instanceof DotProduct); DotProduct portNode2 = (DotProduct) node2; // Note: string3 before string2 IterationStrategyNode node21 = portNode2.get(0); assertTrue(node21 instanceof PortNode); PortNode portNode21 = (PortNode) node21; assertEquals(0, portNode21.getDesiredDepth().intValue()); assertEquals(shape.getInputPorts().getByName("string3"), portNode21.getInputProcessorPort()); IterationStrategyNode node22 = portNode2.get(1); assertTrue(node22 instanceof PortNode); PortNode portNode22 = (PortNode) node22; assertEquals(0, portNode22.getDesiredDepth().intValue()); assertEquals(shape.getInputPorts().getByName("string2"), portNode22.getInputProcessorPort()); }
@Test public void iterationStackNotEqualToDotProduct() throws Exception { IterationStrategyStack itStack = new IterationStrategyStack(); DotProduct dotProd = new DotProduct(); assertNotEquals(itStack, dotProd); } }
iss.add(cp); DotProduct dp = new DotProduct(); PortNode pNode2 = new PortNode(); pNode2.setInputProcessorPort(p2); PortNode pNode3 = new PortNode(); pNode3.setInputProcessorPort(p3); 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; }
iss.add(cp); DotProduct dp = new DotProduct(); PortNode pNode2 = new PortNode(); pNode2.setInputProcessorPort(p2); PortNode pNode3 = new PortNode(); pNode3.setInputProcessorPort(p3); dp.add(pNode2); dp.add(pNode3); PortNode duplicateNode = new PortNode(); duplicateNode.setInputProcessorPort(p1);
@Test public void crossProductNotEqualToDotProduct() throws Exception { DotProduct dotProd = new DotProduct(); CrossProduct crossProd = new CrossProduct(); assertNotEquals(crossProd, dotProd); assertNotEquals(dotProd, crossProd); }
iss.add(cp); DotProduct dp = new DotProduct(); PortNode pNode2 = new PortNode(); pNode2.setInputProcessorPort(p2); PortNode pNode3 = new PortNode(); pNode3.setInputProcessorPort(p3); dp.add(pNode2); dp.add(pNode3); cp.add(dp);
private DotProduct getDot(int depthA, int depthB) { a = new InputProcessorPort(); a.setName("a"); a.setDepth(0); DotProduct dp = new DotProduct(); PortNode nipn1 = new PortNode(dp, a); nipn1.setDesiredDepth(depthA); b = new InputProcessorPort(); b.setName("b"); b.setDepth(0); PortNode nipn2 = new PortNode(dp, b); nipn2.setDesiredDepth(depthB); return dp; }
iss.add(cp); DotProduct dp = new DotProduct(); PortNode pNode2 = new PortNode(); pNode2.setInputProcessorPort(p2); dp.add(pNode2); iss.add(dp);
private DotProduct getDot(int depthA, int depthB) { a = new InputProcessorPort(); a.setName("a"); a.setDepth(0); DotProduct dp = new DotProduct(); PortNode nipn1 = new PortNode(dp, a); nipn1.setDesiredDepth(depthA); b = new InputProcessorPort(); b.setName("b"); b.setDepth(0); PortNode nipn2 = new PortNode(dp, b); nipn2.setDesiredDepth(depthB); return dp; }
iss.add(cp); DotProduct dp = new DotProduct(); PortNode pNode2 = new PortNode(); pNode2.setInputProcessorPort(p2); PortNode pNode3 = new PortNode(); pNode3.setInputProcessorPort(p3); dp.add(pNode2); dp.add(pNode3); iss.add(dp);