summaryrefslogtreecommitdiffstats
path: root/models-errors/src/test
diff options
context:
space:
mode:
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));
+ }
+ }
+}