\r
import java.util.Date;\r
import java.util.List;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+import java.util.UUID;\r
import java.util.Vector;\r
\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
\r
+import org.argeo.slc.core.SlcException;\r
+\r
/**\r
* Basic implementation of a test result containing only a list of result parts.\r
*/\r
public class SimpleTestResult implements TestResult {\r
private static Log log = LogFactory.getLog(SimpleTestResult.class);\r
\r
- private TestResultId testResultId;\r
+ private String uuid;\r
+ private String currentTestRunUuid;\r
+\r
+ private Boolean throwError = true;\r
+\r
private Date closeDate;\r
private List<TestResultPart> parts = new Vector<TestResultPart>();\r
+ \r
+ private Map<String, String> attributes = new TreeMap<String, String>();\r
\r
public void addResultPart(TestResultPart part) {\r
+ if (throwError && part.getStatus() == ERROR) {\r
+ throw new SlcException(\r
+ "There was an error in the underlying test: "\r
+ + part.getExceptionMessage());\r
+ }\r
parts.add(part);\r
if (log.isDebugEnabled())\r
log.debug(part);\r
closeDate = new Date();\r
}\r
\r
- public TestResultId getTestResultId() {\r
- return testResultId;\r
- }\r
-\r
- /** Sets the test result id. */\r
- public void setTestResultId(TestResultId testResultId) {\r
- this.testResultId = testResultId;\r
- }\r
-\r
public List<TestResultPart> getParts() {\r
return parts;\r
}\r
return closeDate;\r
}\r
\r
+ public void setThrowError(Boolean throwError) {\r
+ this.throwError = throwError;\r
+ }\r
+\r
+ public void notifyTestRun(TestRun testRun) {\r
+ currentTestRunUuid = testRun.getUuid();\r
+ }\r
+\r
+ public String getUuid() {\r
+ if (uuid == null) {\r
+ uuid = UUID.randomUUID().toString();\r
+ }\r
+ return uuid;\r
+ }\r
+\r
+ public void setUuid(String uuid) {\r
+ this.uuid = uuid;\r
+ }\r
+\r
+ public String getCurrentTestRunUuid() {\r
+ return currentTestRunUuid;\r
+ }\r
+\r
+ public Map<String, String> getAttributes() {\r
+ return attributes;\r
+ }\r
+\r
}\r