summaryrefslogtreecommitdiffstats
path: root/models-base/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-03-26 09:26:00 +0000
committerliamfallon <liam.fallon@est.tech>2019-03-26 09:26:00 +0000
commit35c6f2df3df2de7f54f717c2167f7b170494cdc9 (patch)
treeda0710bb9dec90881ab5e4b084595af3cbc9d1d0 /models-base/src/test
parentb6649e710c6aad05b6cbb64fa61d6aa0ad82f12a (diff)
Add ErrorResponse to policy framework exceptions
The ErrorResponse object is now contained in Policy Framework exceptions. Issue-ID: POLICY-1095 Change-Id: Ib0ce6cdbbead939afefc4afa3f507eb1a28c4a5c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-base/src/test')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java9
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java11
2 files changed, 12 insertions, 8 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
index 0a5b6a0a6..664e3ddbc 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import javax.ws.rs.core.Response;
import org.junit.Test;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
public class ExceptionsTest {
@@ -41,7 +42,8 @@ public class ExceptionsTest {
String key = "A String";
PfModelException ae =
new PfModelException(Response.Status.OK, "Message", new IOException("IO exception message"), key);
- assertEquals("Message\ncaused by: Message\ncaused by: IO exception message", ae.getCascadedMessage());
+ ErrorResponse errorResponse = ae.getErrorResponse();
+ assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, ae.getObject());
assertNotNull(new PfModelRuntimeException(Response.Status.OK, "Message"));
@@ -52,8 +54,9 @@ public class ExceptionsTest {
String rkey = "A String";
PfModelRuntimeException re = new PfModelRuntimeException(Response.Status.OK, "Runtime Message",
new IOException("IO runtime exception message"), rkey);
- assertEquals("Runtime Message\ncaused by: Runtime Message\ncaused by: IO runtime exception message",
- re.getCascadedMessage());
+ errorResponse = re.getErrorResponse();
+ assertEquals("Runtime Message\nIO runtime exception message",
+ String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, re.getObject());
}
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
index 1257975ad..183b44c13 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
import org.junit.Test;
+import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
/**
* Test PfModelExceptionInfo interface.
@@ -49,15 +50,15 @@ public class PfModelExceptionInfoTest {
}
}
- private String getErrorMessage(final PfModelExceptionInfo pfme) {
+ private String getErrorMessage(final ErrorResponseInfo eri) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Server returned: ");
- stringBuilder.append(pfme.getStatusCode().toString());
+ stringBuilder.append(eri.getErrorResponse().getResponseCode().toString());
+ stringBuilder.append("Error Message:\n");
+ stringBuilder.append(eri.getErrorResponse().getErrorMessage());
stringBuilder.append("\nDetailed Message:\n");
- stringBuilder.append(pfme.getCascadedMessage());
- stringBuilder.append("\nStack Trace:\n");
- stringBuilder.append(pfme.getStackTraceAsString());
+ stringBuilder.append(String.join("\n", eri.getErrorResponse().getErrorDetails()));
return stringBuilder.toString();
}