@SuppressWarnings("unchecked") @Test public void expectedOrder() throws Exception { Workflow wf = new Workflow(); wf.setName("wf"); Processor a = new Processor(wf, "a"); Processor b = new Processor(wf, "b"); Processor c = new Processor(wf, "c"); Processor d = new Processor(wf, "d"); BlockingControlLink b_blocks_c = new BlockingControlLink(c, b); BlockingControlLink a_blocks_c = new BlockingControlLink(c, a); BlockingControlLink a_blocks_b = new BlockingControlLink(b, a); BlockingControlLink b_blocks_d = new BlockingControlLink(d, b); BlockingControlLink a_blocks_d = new BlockingControlLink(d, a); ArrayList<ControlLink> links = new ArrayList<ControlLink>(wf.getControlLinks()); assertEquals(Arrays.asList(a_blocks_b, a_blocks_c, a_blocks_d, b_blocks_c, b_blocks_d), links); Collections.shuffle(links); Collections.sort(links); assertEquals(Arrays.asList(a_blocks_b, a_blocks_c, a_blocks_d, b_blocks_c, b_blocks_d), links); }
Processor d = new Processor(wf, "d"); BlockingControlLink b_blocks_c = new BlockingControlLink(c, b); BlockingControlLink null_blocks_c = new BlockingControlLink(); null_blocks_c.setBlock(c); null_blocks_c.setParent(wf); BlockingControlLink a_blocks_b = new BlockingControlLink(b, a); BlockingControlLink b_blocks_null = new BlockingControlLink(); b_blocks_null.setUntilFinished(b); b_blocks_null.setParent(wf); BlockingControlLink null_blocks_null = new BlockingControlLink(); null_blocks_null.setParent(wf); Collections.sort(links); BlockingControlLink a_blocks_d_no_parent = new BlockingControlLink(); a_blocks_d_no_parent.setBlock(d); a_blocks_d_no_parent.setUntilFinished(a);
protected void parseControlLink(Blocking original) { URI blockUri = getParserState().getCurrentBase().resolve( original.getBlock().getResource()); URI untilFinishedUri = getParserState().getCurrentBase().resolve( original.getUntilFinished().getResource()); WorkflowBean block = resolveBeanUri(blockUri); WorkflowBean untilFinished = resolveBeanUri(untilFinishedUri); BlockingControlLink blocking = new BlockingControlLink(); blocking.setBlock((uk.org.taverna.scufl2.api.core.Processor) block); blocking.setUntilFinished((uk.org.taverna.scufl2.api.core.Processor) untilFinished); blocking.setParent(getParserState().getCurrent(Workflow.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), blocking); }
@Test public void testCorrectnessOfMissingUntilFinished() { BlockingControlLink bcl = new BlockingControlLink(); Processor block = new Processor(); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); assertEquals(0, rcvl.getNullFieldProblems().size()); }
Processor untilFinishedProc = workflow.getProcessors().getByName( untilFinish); new BlockingControlLink(blockProc, untilFinishedProc);
@Test public void testCorrectnessOfMissingBlock() { BlockingControlLink bcl = new BlockingControlLink(); Processor untilFinished = new Processor(); bcl.setUntilFinished(untilFinished); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); assertEquals(0, rcvl.getNullFieldProblems().size()); }
@Test public void testCompletenessOfMissingUntilFinished() { BlockingControlLink bcl = new BlockingControlLink(); Processor block = new Processor(); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(2, rcvl.getNullFieldProblems().size()); // parent and untilFinished boolean nullFieldProblem = false; for (NullFieldProblem nfp : nullFieldProblems) { if (nfp.getBean().equals(bcl) && nfp.getFieldName().equals("untilFinished")) { nullFieldProblem = true; } } assertTrue(nullFieldProblem); }
@Test public void testCompletenessOfMissingBlock() { BlockingControlLink bcl = new BlockingControlLink(); Processor untilFinished = new Processor(); bcl.setUntilFinished(untilFinished); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(2, rcvl.getNullFieldProblems().size()); // parent and block boolean nullFieldProblem = false; for (NullFieldProblem nfp : nullFieldProblems) { if (nfp.getBean().equals(bcl) && nfp.getFieldName().equals("block")) { nullFieldProblem = true; } } assertTrue(nullFieldProblem); }
@Test public void testWronglyScopedBlock() { Workflow wf = new Workflow(); BlockingControlLink bcl = new BlockingControlLink(); bcl.setParent(wf); Processor block = new Processor(); Workflow otherWorkflow = new Workflow(); block.setParent(otherWorkflow); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(1, outOfScopeValueProblems.size()); boolean outOfScopeValueProblem = false; for (OutOfScopeValueProblem oosvp : outOfScopeValueProblems) { if (oosvp.getBean().equals(bcl) && oosvp.getFieldName().equals("block") && oosvp.getValue().equals(block)) { outOfScopeValueProblem = true; } } assertTrue(outOfScopeValueProblem); }
@Test public void testValidlyScopedBlock() { Workflow wf = new Workflow(); BlockingControlLink bcl = new BlockingControlLink(); bcl.setParent(wf); Processor block = new Processor(); block.setParent(wf); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(0, outOfScopeValueProblems.size()); } }
public Workflow makeMainWorkflow() { workflow = new Workflow(); workflow.setName("HelloWorld"); // NOTE: setWorkflowIdentifier should only be called when loading a // workflow // which already has an ID workflow.setIdentifier(URI .create("http://ns.taverna.org.uk/2010/workflow/00626652-55ae-4a9e-80d4-c8e9ac84e2ca/")); InputWorkflowPort yourName = new InputWorkflowPort(workflow, "yourName"); yourName.setDepth(0); OutputWorkflowPort results = new OutputWorkflowPort(workflow, "results"); // Not needed: // workflow.getInputPorts().add(yourName); // workflow.getOutputPorts().add(results); workflow.getProcessors().add(makeProcessor()); workflow.getProcessors().add(makeProcessor2()); // Make links DataLink directLink = new DataLink(workflow, yourName, results); directLink.setMergePosition(1); DataLink greetingLink = new DataLink(workflow, processorGreeting, results); greetingLink.setMergePosition(0); nameLink = new DataLink(workflow, yourName, processorName); condition = new BlockingControlLink(processor, wait4me); return workflow; }