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