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