1 package org
.argeo
.slc
.core
.test
.tree
;
4 import java
.util
.Vector
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
10 import org
.argeo
.slc
.core
.structure
.StructureAware
;
11 import org
.argeo
.slc
.core
.structure
.StructureElement
;
12 import org
.argeo
.slc
.core
.structure
.StructurePath
;
13 import org
.argeo
.slc
.core
.structure
.StructureRegistry
;
14 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
15 import org
.argeo
.slc
.core
.test
.TestDefinition
;
16 import org
.argeo
.slc
.core
.test
.TestResult
;
17 import org
.argeo
.slc
.core
.test
.TestRun
;
19 public class CompositeTreeTestDefinition
implements TestDefinition
,
21 private Log log
= LogFactory
.getLog(CompositeTreeTestDefinition
.class);
23 private List
<TestDefinition
> tasks
= null;
24 private List
<TreeSPath
> taskPaths
= null;
25 private TreeSPath path
;
27 public void execute(TestRun testRun
) {
28 log
.info("Execute sequence of test definitions...");
31 for (TestDefinition task
: tasks
) {
32 TestResult result
= testRun
.getTestResult();
33 if (result
instanceof StructureAware
) {
34 ((StructureAware
) result
).notifyCurrentPath(null, taskPaths
38 task
.execute(testRun
);
40 // Reset current path in case it has been changed
41 if (result
instanceof StructureAware
) {
42 ((StructureAware
) result
).notifyCurrentPath(null, path
);
48 public void setTasks(List
<TestDefinition
> tasks
) {
51 taskPaths
= new Vector
<TreeSPath
>();
55 public void notifyCurrentPath(StructureRegistry registry
, StructurePath path
) {
56 this.path
= (TreeSPath
) path
;
62 for (TestDefinition task
: tasks
) {
63 final StructureElement element
;
64 if (task
instanceof StructureElement
) {
65 element
= (StructureElement
) task
;
67 element
= new SimpleSElement("<no desc>");
69 TreeSPath taskPath
= this.path
.createChild(count
.toString());
70 registry
.register(taskPath
, element
);
71 taskPaths
.add(taskPath
);
72 if (task
instanceof StructureAware
) {
73 ((StructureAware
) task
).notifyCurrentPath(registry
, taskPath
);