2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.core
.test
;
19 import java
.util
.UUID
;
21 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
22 import org
.argeo
.slc
.deploy
.DeployedSystem
;
23 import org
.argeo
.slc
.process
.SlcExecution
;
24 import org
.argeo
.slc
.process
.SlcExecutionRelated
;
25 import org
.argeo
.slc
.process
.SlcExecutionStep
;
26 import org
.argeo
.slc
.structure
.StructureAware
;
27 import org
.argeo
.slc
.structure
.StructureRegistry
;
28 import org
.argeo
.slc
.test
.ExecutableTestRun
;
29 import org
.argeo
.slc
.test
.TestData
;
30 import org
.argeo
.slc
.test
.TestDefinition
;
31 import org
.argeo
.slc
.test
.TestResult
;
32 import org
.argeo
.slc
.test
.WritableTestRun
;
35 * A basic bean implementation of a <code>WritableTestRun</code>, holding
36 * references to the various parts of a test run.
38 @SuppressWarnings("deprecation")
39 public class SimpleTestRun
implements WritableTestRun
, ExecutableTestRun
,
40 SlcExecutionRelated
, StructureAware
<TreeSPath
> {
43 private String slcExecutionUuid
;
44 private String slcExecutionStepUuid
;
46 private TreeSPath path
;
47 private StructureRegistry
<TreeSPath
> registry
;
49 private DeployedSystem deployedSystem
;
50 private TestData testData
;
51 private TestDefinition testDefinition
;
52 private TestResult testResult
;
54 /** Executes the underlying test definition. */
55 @SuppressWarnings("unchecked")
57 uuid
= UUID
.randomUUID().toString();
58 if (testResult
!= null)
59 testResult
.notifyTestRun(this);
62 if (testResult
!= null && path
!= null
63 && testResult
instanceof StructureAware
)
64 ((StructureAware
<TreeSPath
>) testResult
).notifyCurrentPath(
67 if (path
!= null && testDefinition
instanceof StructureAware
)
68 ((StructureAware
<TreeSPath
>) testDefinition
).notifyCurrentPath(
71 testDefinition
.execute(this);
74 @SuppressWarnings("unchecked")
75 public <T
extends DeployedSystem
> T
getDeployedSystem() {
76 return (T
) deployedSystem
;
79 public void setDeployedSystem(DeployedSystem deployedSystem
) {
80 this.deployedSystem
= deployedSystem
;
83 @SuppressWarnings("unchecked")
84 public <T
extends TestData
> T
getTestData() {
88 public void setTestData(TestData testData
) {
89 this.testData
= testData
;
92 @SuppressWarnings("unchecked")
93 public <T
extends TestDefinition
> T
getTestDefinition() {
94 return (T
) testDefinition
;
97 public void setTestDefinition(TestDefinition testDefinition
) {
98 this.testDefinition
= testDefinition
;
101 @SuppressWarnings("unchecked")
102 public <T
extends TestResult
> T
getTestResult() {
103 return (T
) testResult
;
106 public void setTestResult(TestResult testResult
) {
107 this.testResult
= testResult
;
110 public String
getUuid() {
114 public void setUuid(String uuid
) {
118 public String
getSlcExecutionUuid() {
119 return slcExecutionUuid
;
122 public void setSlcExecutionUuid(String slcExecutionUuid
) {
123 this.slcExecutionUuid
= slcExecutionUuid
;
126 public String
getSlcExecutionStepUuid() {
127 return slcExecutionStepUuid
;
130 public void setSlcExecutionStepUuid(String slcExecutionStepUuid
) {
131 this.slcExecutionStepUuid
= slcExecutionStepUuid
;
135 public void notifySlcExecution(SlcExecution slcExecution
) {
136 if (slcExecution
!= null) {
137 slcExecutionUuid
= slcExecution
.getUuid();
138 SlcExecutionStep step
= slcExecution
.currentStep();
140 slcExecutionStepUuid
= step
.getUuid();
145 public void notifyCurrentPath(StructureRegistry
<TreeSPath
> registry
,
147 this.registry
= registry
;