1 package org
.argeo
.slc
.core
.test
.tree
;
4 import java
.util
.SortedMap
;
5 import java
.util
.TreeMap
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.slc
.core
.SlcException
;
11 import org
.argeo
.slc
.core
.structure
.StructureAware
;
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
.NumericTRId
;
16 import org
.argeo
.slc
.core
.test
.TestResult
;
17 import org
.argeo
.slc
.core
.test
.TestResultId
;
18 import org
.argeo
.slc
.core
.test
.TestResultListener
;
19 import org
.argeo
.slc
.core
.test
.TestResultPart
;
21 public class TreeTestResult
implements TestResult
, StructureAware
{
22 private Log log
= LogFactory
.getLog(TreeTestResult
.class);
26 private NumericTRId testResultId
;
27 private List
<TestResultListener
> listeners
;
29 private TreeSPath currentPath
;
31 private boolean isClosed
= false;
33 private SortedMap
<TreeSPath
, PartSubList
> resultParts
= new TreeMap
<TreeSPath
, PartSubList
>();
35 public TestResultId
getTestResultId() {
39 public NumericTRId
getNumericResultId() {
43 public void setNumericResultId(NumericTRId testResultId
) {
44 this.testResultId
= testResultId
;
47 public void setListeners(List
<TestResultListener
> listeners
) {
48 this.listeners
= listeners
;
51 public void addResultPart(TestResultPart part
) {
52 if (currentPath
== null) {
53 throw new SlcException("No current path set.");
55 PartSubList subList
= resultParts
.get(currentPath
);
56 if (subList
== null) {
57 subList
= new PartSubList();
58 resultParts
.put(currentPath
, subList
);
60 subList
.getParts().add(part
);
63 synchronized (listeners
) {
64 for (TestResultListener listener
: listeners
) {
65 listener
.resultPartAdded(this, part
);
70 public void notifyCurrentPath(StructureRegistry registry
, StructurePath path
) {
71 currentPath
= (TreeSPath
) path
;
74 public TreeSPath
getCurrentPath() {
78 public SortedMap
<TreeSPath
, PartSubList
> getResultParts() {
82 void setResultParts(SortedMap
<TreeSPath
, PartSubList
> resultParts
) {
83 this.resultParts
= resultParts
;
88 throw new SlcException("Test Result #"+getTestResultId()+" alredy closed.");
91 synchronized (listeners
) {
92 for (TestResultListener listener
: listeners
) {
98 log
.info("Test Result #"+getTestResultId()+" closed.");
105 void setTid(Long tid
) {