]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java
Clarify SLC project structure.
[gpl/argeo-slc.git] / cms / org.argeo.slc.runtime / src / org / argeo / slc / runtime / test / SimpleTestResult.java
1 package org.argeo.slc.runtime.test;
2
3 import java.util.Date;
4 import java.util.List;
5 import java.util.Map;
6 import java.util.TreeMap;
7 import java.util.UUID;
8 import java.util.Vector;
9
10 import org.apache.commons.logging.Log;
11 import org.apache.commons.logging.LogFactory;
12 import org.argeo.slc.SlcException;
13 import org.argeo.slc.test.TestResult;
14 import org.argeo.slc.test.TestResultPart;
15 import org.argeo.slc.test.TestRun;
16
17 /**
18 * Basic implementation of a test result containing only a list of result parts.
19 */
20 public class SimpleTestResult implements TestResult {
21 private static Log log = LogFactory.getLog(SimpleTestResult.class);
22
23 private String uuid;
24 private String currentTestRunUuid;
25
26 private Boolean throwError = true;
27
28 private Date closeDate;
29 private List<TestResultPart> parts = new Vector<TestResultPart>();
30
31 private Map<String, String> attributes = new TreeMap<String, String>();
32
33 public void addResultPart(TestResultPart part) {
34 if (throwError && part.getStatus() == ERROR) {
35 throw new SlcException(
36 "There was an error in the underlying test: "
37 + part.getExceptionMessage());
38 }
39 parts.add(part);
40 if (log.isDebugEnabled())
41 log.debug(part);
42 }
43
44 public void close() {
45 parts.clear();
46 closeDate = new Date();
47 }
48
49 public List<TestResultPart> getParts() {
50 return parts;
51 }
52
53 public Date getCloseDate() {
54 return closeDate;
55 }
56
57 public void setThrowError(Boolean throwError) {
58 this.throwError = throwError;
59 }
60
61 public void notifyTestRun(TestRun testRun) {
62 currentTestRunUuid = testRun.getUuid();
63 }
64
65 public String getUuid() {
66 if (uuid == null) {
67 uuid = UUID.randomUUID().toString();
68 }
69 return uuid;
70 }
71
72 public void setUuid(String uuid) {
73 this.uuid = uuid;
74 }
75
76 public String getCurrentTestRunUuid() {
77 return currentTestRunUuid;
78 }
79
80 public Map<String, String> getAttributes() {
81 return attributes;
82 }
83
84 public void setAttributes(Map<String, String> attributes) {
85 this.attributes = attributes;
86 }
87
88 }