@Test public void iterationStackEqualIfEmpty() throws Exception { IterationStrategyStack itStack1 = new IterationStrategyStack(); IterationStrategyStack itStack2 = new IterationStrategyStack(); assertEquals(itStack1, itStack2); }
@Test public void iterationStackNotEqualToCrossProduct() throws Exception { IterationStrategyStack itStack = new IterationStrategyStack(); CrossProduct crossProd = new CrossProduct(); assertNotEquals(itStack, crossProd); }
@Test public void iterationStackNotEqualToDotProduct() throws Exception { IterationStrategyStack itStack = new IterationStrategyStack(); DotProduct dotProd = new DotProduct(); assertNotEquals(itStack, dotProd); } }
protected IterationStrategyStack parseIterationStrategyStack( org.apache.taverna.scufl2.xml.t2flow.jaxb.IterationStrategyStack originalStack) throws ReaderException { IterationStrategyStack newStack = new IterationStrategyStack(); for (TopIterationNode strategy : originalStack.getIteration() .getStrategy()) { IterationNode topNode = strategy.getCross(); if (topNode == null) topNode = strategy.getDot(); if (topNode == null) continue; IterationNodeParent parent = (IterationNodeParent) topNode; if (parent.getCrossOrDotOrPort().isEmpty()) continue; try { newStack.add((IterationStrategyTopNode) parseIterationStrategyNode(topNode)); } catch (ReaderException e) { if (isStrict()) throw e; logger.warning(e.getMessage()); } } return newStack; }
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; }
@Test public void testStagedCombinationOfDot1() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(2), sv.calculateResultWrappingDepth(tempDepths)); }
@Test public void testStagedCombinationOfCross() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getCross(1, 1)); iss.add(getCross(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(4), sv.calculateResultWrappingDepth(tempDepths)); }
@Test public void testStagedCombinationOfDot3() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,1); tempDepths.put(b,0); // Slightly strange superficially that this should work, but in fact // what happens is that the first single item is lifted to a list before // being passed to the iteration strategy. The result is that it's fine // to match with the dot product against the other list as neither at // this point have index arrays, then in the second stage both are lists // to be iterated over and both have single length index arrays. assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths)); } }
protected void parseIterationStrategyStack(IterationStrategyStack original) throws ReaderException { org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack iterationStrategyStack = new org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack(); iterationStrategyStack.setParent(getParserState().getCurrent( Processor.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), iterationStrategyStack); if (original.getIterationStrategies() != null) { getParserState().push(iterationStrategyStack); try { parseCrossDotOrPortNodeList(original.getIterationStrategies() .getDotProductOrCrossProduct()); } finally { getParserState().pop(); } } }
@Test public void testStagedCombinationOfDot2() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,0); tempDepths.put(b,0); // Should pass because the single items (depth 0) are promoted to single // item lists before being passed into the iteration system so are // effectively both depth 1 going into the second stage which then // iterates to produce an index array length of 1 assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths)); }
/** * Test whether Paul's example of iterating with dot product then cross * product can typecheck in a single staged iteration. This was an example * where the user had two lists of folders (a1, a2, b1, b2, c1, c2) and * wanted to compare all the contents of each 'a' folder with the other 'a' * folder and so on, doing a dot match to only compare a1 and a2 then a * cross product join within each pair to compare all contents of a1 with * all contents of a2. This appears to work! */ @Test public void testStagedCombinationOfDotAndCross() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getCross(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(3), sv.calculateResultWrappingDepth(tempDepths)); }
InputProcessorPort ipp = new InputProcessorPort(); IterationStrategyStack iss = new IterationStrategyStack(); p.setIterationStrategyStack(iss); CrossProduct cp = new CrossProduct();
@Test public void testSimpleIteration() { WorkflowBundle wb = new WorkflowBundle(); Workflow w = new Workflow(); wb.setMainWorkflow(w); InputWorkflowPort a = new InputWorkflowPort(w, "a"); a.setDepth(1); Processor p = new Processor(w, "p"); InputProcessorPort ipp = new InputProcessorPort(p, "in"); ipp.setDepth(0); OutputProcessorPort opp = new OutputProcessorPort(p, "out"); opp.setDepth(3); DataLink inLink = new DataLink(w, a, ipp); IterationStrategyStack iss = new IterationStrategyStack(p); CrossProduct cp = new CrossProduct(); iss.add(cp); PortNode portNode = new PortNode(cp, ipp); portNode.setDesiredDepth(0); StructuralValidator sv = new StructuralValidator(); ReportStructuralValidationListener l = new ReportStructuralValidationListener(); sv.checkStructure(wb, l); ValidatorState vs = sv.getValidatorState(); assertEquals(0, l.getIncompleteWorkflows().size()); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(a)); assertEquals(Integer.valueOf(1), vs.getDataLinkResolvedDepth(inLink)); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(ipp)); assertEquals(Integer.valueOf(4), vs.getPortResolvedDepth(opp)); }
@Test public void testInvalidIterationStrategyStack() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(); iss.setParent(p);
@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 testInvalidAtTopIterationStrategyTopNode() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(); iss.setParent(p);
@Test public void testInvalidDeepInIterationStrategyTopNode() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(); iss.setParent(p);
@Test public void testValidIterationStrategyTopNode() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(); iss.setParent(p);
@Test public void testValidIterationStrategyStack() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(); iss.setParent(p);