X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2FSimpleTestResult.java;h=c1d783a77618bfc7f9309d0dfc256393683a0a7f;hb=42aa6ffce6a95107cd10f908e5f9c695d902d571;hp=9ef6cdea3e95da55b9c351b625be73b2f62de92b;hpb=faf680e212bf3e18837c4f798587856e061273b3;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java index 9ef6cdea3..c1d783a77 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java @@ -2,22 +2,34 @@ package org.argeo.slc.core.test; import java.util.Date; import java.util.List; +import java.util.UUID; import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.core.SlcException; + /** * Basic implementation of a test result containing only a list of result parts. */ public class SimpleTestResult implements TestResult { private static Log log = LogFactory.getLog(SimpleTestResult.class); - private TestResultId testResultId; + private String uuid; + private String currentTestRunUuid; + + private Boolean throwError = true; + private Date closeDate; private List parts = new Vector(); public void addResultPart(TestResultPart part) { + if (throwError && part.getStatus() == ERROR) { + throw new SlcException( + "There was an error in the underlying test: " + + part.getExceptionMessage()); + } parts.add(part); if (log.isDebugEnabled()) log.debug(part); @@ -28,15 +40,6 @@ public class SimpleTestResult implements TestResult { closeDate = new Date(); } - public TestResultId getTestResultId() { - return testResultId; - } - - /** Sets the test result id. */ - public void setTestResultId(TestResultId testResultId) { - this.testResultId = testResultId; - } - public List getParts() { return parts; } @@ -45,4 +48,27 @@ public class SimpleTestResult implements TestResult { return closeDate; } + public void setThrowError(Boolean throwError) { + this.throwError = throwError; + } + + public void notifyTestRun(TestRun testRun) { + currentTestRunUuid = testRun.getUuid(); + } + + public String getUuid() { + if (uuid == null) { + uuid = UUID.randomUUID().toString(); + } + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCurrentTestRunUuid() { + return currentTestRunUuid; + } + }