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