summaryrefslogtreecommitdiffstats
path: root/models-base/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'models-base/src/test')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java21
1 files changed, 19 insertions, 2 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 112f6a203..52d17e74f 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.junit.Test;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -60,5 +61,21 @@ public class ExceptionsTest {
assertEquals("Runtime Message\nIO runtime exception message",
String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, re.getObject());
+
+ PfModelRuntimeException pfre = new PfModelRuntimeException(ae);
+ assertEquals(ae.getErrorResponse().getResponseCode(), pfre.getErrorResponse().getResponseCode());
+ assertEquals(ae.getMessage(), pfre.getMessage());
+
+ try {
+ try {
+ throw new PfModelException(Status.BAD_GATEWAY, "An Exception");
+ } catch (PfModelException pfme) {
+ throw new PfModelRuntimeException(pfme);
+ }
+ } catch (PfModelRuntimeException pfmre) {
+ assertEquals(Status.BAD_GATEWAY, pfmre.getErrorResponse().getResponseCode());
+ assertEquals("An Exception", pfmre.getMessage());
+ assertEquals(PfModelException.class.getName(), pfmre.getCause().getClass().getName());
+ }
}
}