1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.jobscheduler.impl.groovy;
12
13 import org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase;
14 import org.astrogrid.workflow.beans.v1.For;
15 import org.astrogrid.workflow.beans.v1.Script;
16 import org.astrogrid.workflow.beans.v1.Set;
17 import org.astrogrid.workflow.beans.v1.Workflow;
18 import org.astrogrid.workflow.beans.v1.execution.StepExecutionRecord;
19
20 /***
21 * @author Noel Winstanley nw@jb.man.ac.uk 05-Aug-2004
22 *
23 */
24 public class ForSingletonFeatureTest extends AbstractTestForFeature {
25
26 /*** Construct a new ForSingletonFeatureTest
27 * @param name
28 */
29 public ForSingletonFeatureTest(String name) {
30 super(name);
31 }
32
33 /***
34 * @see org.astrogrid.jes.jobscheduler.impl.groovy.AbstractTestForFeature#buildWorkflow()
35 */
36 protected Workflow buildWorkflow() {
37 Workflow wf = super.createMinimalWorkflow();
38 Set acc = new Set();
39 acc.setVar("acc");
40 acc.setValue("${0}");
41 wf.getSequence().addActivity(acc);
42
43 For f = new For();
44 f.setVar("i");
45 f.setItems("${[1]}");
46
47 Script sc = new Script();
48 sc.setBody("acc = acc + i");
49 f.setActivity(sc);
50
51 wf.getSequence().addActivity(f);
52
53 Script end = new Script();
54 end.setBody("print (acc == 1)");
55 wf.getSequence().addActivity(end);
56
57 return wf;
58 }
59
60 /***
61 * @see org.astrogrid.jes.jobscheduler.impl.groovy.AbstractTestForFeature#verifyWorkflow(org.astrogrid.workflow.beans.v1.Workflow)
62 */
63 protected void verifyWorkflow(Workflow result) {
64 assertWorkflowCompleted(result);
65 Script body = (Script)((For)result.getSequence().getActivity(1)).getActivity();
66 assertEquals(1,body.getStepExecutionRecordCount());
67 for (int i = 0; i < body.getStepExecutionRecordCount(); i++) {
68 StepExecutionRecord rec = body.getStepExecutionRecord(i);
69 assertEquals(ExecutionPhase.COMPLETED,rec.getStatus());
70 assertTrue(rec.getMessageCount() > 0);
71 }
72
73 Script end = (Script)result.getSequence().getActivity(2);
74 assertScriptCompletedWithMessage(end,"true");
75 }
76
77
78 }
79
80
81
82
83
84
85
86