]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
Various changes
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index 8da3e7d5a2dde3bd932a5175b592cbac6d3c77a8..9b807c904be55023d0ab614273c3a442c51e629d 100644 (file)
@@ -10,9 +10,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;\r
 \r
 import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionAware;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
 import org.argeo.slc.core.structure.StructureAware;\r
 import org.argeo.slc.core.structure.StructureElement;\r
 import org.argeo.slc.core.structure.StructureRegistry;\r
@@ -20,20 +17,20 @@ import org.argeo.slc.core.structure.tree.TreeSPath;
 import org.argeo.slc.core.test.TestResult;\r
 import org.argeo.slc.core.test.TestResultListener;\r
 import org.argeo.slc.core.test.TestResultPart;\r
+import org.argeo.slc.core.test.TestRun;\r
+import org.argeo.slc.core.test.TestRunAware;\r
 \r
 /**\r
  * Complex implementation of a test result compatible with a tree based\r
  * structure.\r
  */\r
-public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,\r
-               SlcExecutionAware {\r
+public class TreeTestResult implements TestResult, StructureAware<TreeSPath> {\r
        private Log log = LogFactory.getLog(TreeTestResult.class);\r
 \r
        private List<TestResultListener> listeners = new Vector<TestResultListener>();\r
 \r
        private TreeSPath currentPath;\r
-       private String currentSlcExecutionUuid;\r
-       private String currentSlcExecutionStepUuid;\r
+       private TestRun currentTestRun;\r
 \r
        private Date closeDate;\r
 \r
@@ -56,10 +53,11 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                PartSubList subList = resultParts.get(currentPath);\r
                if (subList == null) {\r
                        subList = new PartSubList();\r
-                       subList.setSlcExecutionUuid(currentSlcExecutionUuid);\r
-                       subList.setSlcExecutionStepUuid(currentSlcExecutionStepUuid);\r
                        resultParts.put(currentPath, subList);\r
                }\r
+               if (part instanceof TestRunAware && currentTestRun != null) {\r
+                       ((TestRunAware) part).notifyTestRun(currentTestRun);\r
+               }\r
                subList.getParts().add(part);\r
 \r
                // notify listeners\r
@@ -133,12 +131,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                this.closeDate = closeDate;\r
        }\r
 \r
-       public void notifySlcExecution(SlcExecution slcExecution) {\r
-               currentSlcExecutionUuid = slcExecution.getUuid();\r
-               SlcExecutionStep step = slcExecution.currentStep();\r
-               if (step != null) {\r
-                       currentSlcExecutionStepUuid = step.getUuid();\r
-               }\r
+       public void notifyTestRun(TestRun testRun) {\r
+               currentTestRun = testRun;\r
        }\r
 \r
        public SortedMap<TreeSPath, StructureElement> getElements() {\r
@@ -157,4 +151,21 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                this.uuid = uuid;\r
        }\r
 \r
+       public SortedMap<TreeSPath, StructureElement> getRelatedElements(\r
+                       TreeSPath path) {\r
+               SortedMap<TreeSPath, StructureElement> relatedElements = new TreeMap<TreeSPath, StructureElement>();\r
+               List<TreeSPath> hierarchy = path.getHierarchyAsList();\r
+               for (TreeSPath currPath : elements.keySet()) {\r
+                       if (hierarchy.contains(currPath)) {\r
+                               relatedElements.put(currPath, elements.get(currPath));\r
+                       }\r
+               }\r
+               return relatedElements;\r
+       }\r
+\r
+       public TestRun getCurrentTestRun() {\r
+               return currentTestRun;\r
+       }\r
+       \r
+       \r
 }\r