]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java
Fix issue with RealizedFlow XML too big
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / SimpleTestRun.java
1 package org.argeo.slc.core.test;
2
3 import java.util.UUID;
4
5 import org.argeo.slc.core.structure.tree.TreeSPath;
6 import org.argeo.slc.deploy.DeployedSystem;
7 import org.argeo.slc.process.SlcExecution;
8 import org.argeo.slc.process.SlcExecutionRelated;
9 import org.argeo.slc.process.SlcExecutionStep;
10 import org.argeo.slc.structure.StructureAware;
11 import org.argeo.slc.structure.StructureRegistry;
12 import org.argeo.slc.test.ExecutableTestRun;
13 import org.argeo.slc.test.TestData;
14 import org.argeo.slc.test.TestDefinition;
15 import org.argeo.slc.test.TestResult;
16 import org.argeo.slc.test.WritableTestRun;
17
18 /**
19 * A basic bean implementation of a <code>WritableTestRun</code>, holding
20 * references to the various parts of a test run.
21 */
22 public class SimpleTestRun implements WritableTestRun, ExecutableTestRun,
23 SlcExecutionRelated, StructureAware<TreeSPath> {
24 private String uuid;
25
26 private String slcExecutionUuid;
27 private String slcExecutionStepUuid;
28
29 private TreeSPath path;
30 private StructureRegistry<TreeSPath> registry;
31
32 private DeployedSystem deployedSystem;
33 private TestData testData;
34 private TestDefinition testDefinition;
35 private TestResult testResult;
36
37 /** Executes the underlying test definition. */
38 @SuppressWarnings("unchecked")
39 public void run() {
40 uuid = UUID.randomUUID().toString();
41 if (testResult != null)
42 testResult.notifyTestRun(this);
43
44 // Structure
45 if (testResult != null && path != null
46 && testResult instanceof StructureAware)
47 ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(
48 registry, path);
49
50 if (path != null && testDefinition instanceof StructureAware)
51 ((StructureAware<TreeSPath>) testDefinition).notifyCurrentPath(
52 registry, path);
53
54 testDefinition.execute(this);
55 }
56
57 @SuppressWarnings("unchecked")
58 public <T extends DeployedSystem> T getDeployedSystem() {
59 return (T) deployedSystem;
60 }
61
62 public void setDeployedSystem(DeployedSystem deployedSystem) {
63 this.deployedSystem = deployedSystem;
64 }
65
66 @SuppressWarnings("unchecked")
67 public <T extends TestData> T getTestData() {
68 return (T) testData;
69 }
70
71 public void setTestData(TestData testData) {
72 this.testData = testData;
73 }
74
75 @SuppressWarnings("unchecked")
76 public <T extends TestDefinition> T getTestDefinition() {
77 return (T) testDefinition;
78 }
79
80 public void setTestDefinition(TestDefinition testDefinition) {
81 this.testDefinition = testDefinition;
82 }
83
84 @SuppressWarnings("unchecked")
85 public <T extends TestResult> T getTestResult() {
86 return (T) testResult;
87 }
88
89 public void setTestResult(TestResult testResult) {
90 this.testResult = testResult;
91 }
92
93 public String getUuid() {
94 return uuid;
95 }
96
97 public void setUuid(String uuid) {
98 this.uuid = uuid;
99 }
100
101 public String getSlcExecutionUuid() {
102 return slcExecutionUuid;
103 }
104
105 public void setSlcExecutionUuid(String slcExecutionUuid) {
106 this.slcExecutionUuid = slcExecutionUuid;
107 }
108
109 public String getSlcExecutionStepUuid() {
110 return slcExecutionStepUuid;
111 }
112
113 public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {
114 this.slcExecutionStepUuid = slcExecutionStepUuid;
115 }
116
117 public void notifySlcExecution(SlcExecution slcExecution) {
118 if (slcExecution != null) {
119 slcExecutionUuid = slcExecution.getUuid();
120 SlcExecutionStep step = slcExecution.currentStep();
121 if (step != null) {
122 slcExecutionStepUuid = step.getUuid();
123 }
124 }
125 }
126
127 public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,
128 TreeSPath path) {
129 this.registry = registry;
130 this.path = path;
131 }
132
133 }