summaryrefslogtreecommitdiffstats
path: root/models-errors/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-errors/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-errors/src/test')
-rw-r--r--models-errors/src/test/java/org/onap/policy/models/errors/concepts/ErrorResponseUtilsTest.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/models-errors/src/test/java/org/onap/policy/models/errors/concepts/ErrorResponseUtilsTest.java b/models-errors/src/test/java/org/onap/policy/models/errors/concepts/ErrorResponseUtilsTest.java
new file mode 100644
index 000000000..4f4ef395a
--- /dev/null
+++ b/models-errors/src/test/java/org/onap/policy/models/errors/concepts/ErrorResponseUtilsTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.errors.concepts;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+/**
+ * Test the {@link ErrorResponseUtils} class.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ErrorResponseUtilsTest {
+ @Test
+ public void testErrorResponseUtils() {
+ try {
+ try {
+ throw new NumberFormatException("Exception 0");
+ }
+ catch (Exception nfe) {
+ throw new IOException("Exception 1", nfe);
+ }
+ } catch (Exception ioe) {
+ ErrorResponse errorResponse = new ErrorResponse();
+ ErrorResponseUtils.getExceptionMessages(errorResponse, ioe);
+
+ assertEquals("Exception 1", errorResponse.getErrorMessage());
+ assertEquals("Exception 1", errorResponse.getErrorDetails().get(0));
+ assertEquals("Exception 0", errorResponse.getErrorDetails().get(1));
+ }
+ }
+}